]> Kevux Git Server - controller/commitdiff
Bugfix: Controller is adding an extra '/' to the file name.
authorKevin Day <Kevin@kevux.org>
Fri, 12 Jul 2024 03:52:34 +0000 (22:52 -0500)
committerKevin Day <Kevin@kevux.org>
Fri, 12 Jul 2024 03:52:34 +0000 (22:52 -0500)
This does not cause a problem unless the local filesystem is very picky about extra slashes.

The error printing revealed the problem as descibed in the examples below.

Example Incorrect Error Message:
  ERROR: Unable to open file './/entries/utility.entry', could not find.

Example Correct Error Message:
  ERROR: Unable to open file './entries/utility.entry', could not find.

sources/c/main/file.c

index a90981c13b88e22a12a9043f81f4d29bb3fdf219..f7ed3a66b1665b89fbadfab148e56d158231ccb6 100644 (file)
@@ -43,7 +43,11 @@ extern "C" {
     f_string_static_t path = f_string_static_t_initialize;
 
     if (main->process.path_setting.used) {
-      path.used = main->process.path_setting.used + F_path_separator_s_length + main->thread.cache.action.name_file.used;
+      path.used = main->process.path_setting.used + main->thread.cache.action.name_file.used;
+
+      if (main->process.path_setting.string[main->process.path_setting.used - 1] != f_path_separator_s.string[0]) {
+        path.used += f_path_separator_s.used;
+      }
     }
     else {
       path.used = main->thread.cache.action.name_file.used;
@@ -54,9 +58,15 @@ extern "C" {
 
     if (main->process.path_setting.used) {
       memcpy(path_string, main->process.path_setting.string, sizeof(f_char_t) * main->process.path_setting.used);
-      memcpy(path_string + main->process.path_setting.used + F_path_separator_s_length, main->thread.cache.action.name_file.string, sizeof(f_char_t) * main->thread.cache.action.name_file.used);
 
-      path_string[main->process.path_setting.used] = f_path_separator_s.string[0];
+      if (main->process.path_setting.string[main->process.path_setting.used - 1] == f_path_separator_s.string[0]) {
+        memcpy(path_string + main->process.path_setting.used, main->thread.cache.action.name_file.string, sizeof(f_char_t) * main->thread.cache.action.name_file.used);
+      }
+      else {
+        memcpy(path_string + main->process.path_setting.used + F_path_separator_s_length, main->thread.cache.action.name_file.string, sizeof(f_char_t) * main->thread.cache.action.name_file.used);
+
+        path_string[main->process.path_setting.used] = f_path_separator_s.string[0];
+      }
     }
     else {
       memcpy(path_string, main->thread.cache.action.name_file.string, sizeof(f_char_t) * main->thread.cache.action.name_file.used);
@@ -64,7 +74,6 @@ extern "C" {
 
     path_string[path.used] = 0;
 
-
     status = f_file_stream_open(path, f_string_empty_s, &file);
 
     if (F_status_is_error(status)) {