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.7 by cebix, 1999-11-08T16:43:11Z vs.
Revision 1.9 by cebix, 1999-11-08T18:06:00Z

# Line 368 | 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