ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/extfs_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/extfs_unix.cpp (file contents):
Revision 1.5 by cebix, 1999-10-27T16:59:45Z vs.
Revision 1.9 by cebix, 1999-11-08T18:06:00Z

# Line 85 | Line 85 | struct finf_struct {
85          uint32 type;
86          uint32 creator;
87          uint16 flags;
88 +        uint16 pad0;
89   };
90  
91   static void make_helper_path(const char *src, char *dest, const char *add, bool only_dir = false)
# Line 114 | Line 115 | static int create_helper_dir(const char
115   {
116          char helper_dir[MAX_PATH_LENGTH];
117          make_helper_path(path, helper_dir, add, true);
118 <        return mkdir(helper_dir, 0755);
118 >        return mkdir(helper_dir, 0777);
119   }
120  
121   static int open_helper(const char *path, const char *add, int flag)
# Line 122 | Line 123 | static int open_helper(const char *path,
123          char helper_path[MAX_PATH_LENGTH];
124          make_helper_path(path, helper_path, add);
125  
126 <        if ((flag & O_RDWR) || (flag && O_WRONLY))
126 >        if ((flag & O_ACCMODE) == O_RDWR || (flag & O_ACCMODE) == O_WRONLY)
127                  flag |= O_CREAT;
128 <        int fd = open(helper_path, flag, 0644);
128 >        int fd = open(helper_path, flag, 0666);
129          if (fd < 0) {
130                  if (errno == ENOENT && (flag & O_CREAT)) {
131                          // One path component was missing, probably the helper
# Line 132 | Line 133 | static int open_helper(const char *path,
133                          int ret = create_helper_dir(path, add);
134                          if (ret < 0)
135                                  return ret;
136 <                        fd = open(helper_path, flag, 0644);
136 >                        fd = open(helper_path, flag, 0666);
137                  }
138          }
139          return fd;
# Line 258 | Line 259 | void set_finder_type(const char *path, u
259                  return;
260  
261          // Read file
262 <        finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS};
262 >        finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS, 0};
263          read(fd, &finf, sizeof(finf_struct));
264  
265          // Set Finder flags
# Line 302 | Line 303 | void set_finder_flags(const char *path,
303                  return;
304  
305          // Read file
306 <        finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS};
306 >        finf_struct finf = {0, 0, DEFAULT_FINDER_FLAGS, 0};
307          read(fd, &finf, sizeof(finf_struct));
308  
309          // Set Finder flags
# Line 367 | Line 368 | size_t extfs_write(int fd, void *buffer,
368          errno = 0;
369          return write(fd, buffer, length);
370   }
371 +
372 +
373 + /*
374 + *  Remove file/directory (and associated helper files),
375 + *  returns false on error (and sets errno)
376 + */
377 +
378 + bool extfs_remove(const char *path)
379 + {
380 +        // Remove helpers first, don't complain if this fails
381 +        char helper_path[MAX_PATH_LENGTH];
382 +        make_helper_path(path, helper_path, ".finf/", false);
383 +        remove(helper_path);
384 +        make_helper_path(path, helper_path, ".rsrc/", false);
385 +        remove(helper_path);
386 +
387 +        // Now remove file or directory (and helper directories in the directory)
388 +        if (remove(path) < 0) {
389 +                if (errno == EISDIR || errno == ENOTEMPTY) {
390 +                        helper_path[0] = 0;
391 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
392 +                        add_path_component(helper_path, ".finf");
393 +                        rmdir(helper_path);
394 +                        helper_path[0] = 0;
395 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
396 +                        add_path_component(helper_path, ".rsrc");
397 +                        rmdir(helper_path);
398 +                        return rmdir(path) == 0;
399 +                } else
400 +                        return false;
401 +        }
402 +        return true;
403 + }
404 +
405 +
406 + /*
407 + *  Rename/move file/directory (and associated helper files),
408 + *  returns false on error (and sets errno)
409 + */
410 +
411 + bool extfs_rename(const char *old_path, const char *new_path)
412 + {
413 +        // Rename helpers first, don't complain if this fails
414 +        char old_helper_path[MAX_PATH_LENGTH], new_helper_path[MAX_PATH_LENGTH];
415 +        make_helper_path(old_path, old_helper_path, ".finf/", false);
416 +        make_helper_path(new_path, new_helper_path, ".finf/", false);
417 +        create_helper_dir(new_path, ".finf/");
418 +        rename(old_helper_path, new_helper_path);
419 +        make_helper_path(old_path, old_helper_path, ".rsrc/", false);
420 +        make_helper_path(new_path, new_helper_path, ".rsrc/", false);
421 +        create_helper_dir(new_path, ".rsrc/");
422 +        rename(old_helper_path, new_helper_path);
423 +
424 +        // Now rename file
425 +        return rename(old_path, new_path) == 0;
426 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines