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.10 by cebix, 1999-12-22T16:16:16Z

# Line 348 | Line 348 | void close_rfork(const char *path, int f
348  
349   /*
350   *  Read "length" bytes from file to "buffer",
351 < *  returns number of bytes read (or 0)
351 > *  returns number of bytes read (or -1 on error)
352   */
353  
354 < size_t extfs_read(int fd, void *buffer, size_t length)
354 > ssize_t extfs_read(int fd, void *buffer, size_t length)
355   {
356        errno = 0;
356          return read(fd, buffer, length);
357   }
358  
359  
360   /*
361   *  Write "length" bytes from "buffer" to file,
362 < *  returns number of bytes written (or 0)
362 > *  returns number of bytes written (or -1 on error)
363   */
364  
365 < size_t extfs_write(int fd, void *buffer, size_t length)
365 > ssize_t extfs_write(int fd, void *buffer, size_t length)
366   {
368        errno = 0;
367          return write(fd, buffer, length);
368   }
369 +
370 +
371 + /*
372 + *  Remove file/directory (and associated helper files),
373 + *  returns false on error (and sets errno)
374 + */
375 +
376 + bool extfs_remove(const char *path)
377 + {
378 +        // Remove helpers first, don't complain if this fails
379 +        char helper_path[MAX_PATH_LENGTH];
380 +        make_helper_path(path, helper_path, ".finf/", false);
381 +        remove(helper_path);
382 +        make_helper_path(path, helper_path, ".rsrc/", false);
383 +        remove(helper_path);
384 +
385 +        // Now remove file or directory (and helper directories in the directory)
386 +        if (remove(path) < 0) {
387 +                if (errno == EISDIR || errno == ENOTEMPTY) {
388 +                        helper_path[0] = 0;
389 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
390 +                        add_path_component(helper_path, ".finf");
391 +                        rmdir(helper_path);
392 +                        helper_path[0] = 0;
393 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
394 +                        add_path_component(helper_path, ".rsrc");
395 +                        rmdir(helper_path);
396 +                        return rmdir(path) == 0;
397 +                } else
398 +                        return false;
399 +        }
400 +        return true;
401 + }
402 +
403 +
404 + /*
405 + *  Rename/move file/directory (and associated helper files),
406 + *  returns false on error (and sets errno)
407 + */
408 +
409 + bool extfs_rename(const char *old_path, const char *new_path)
410 + {
411 +        // Rename helpers first, don't complain if this fails
412 +        char old_helper_path[MAX_PATH_LENGTH], new_helper_path[MAX_PATH_LENGTH];
413 +        make_helper_path(old_path, old_helper_path, ".finf/", false);
414 +        make_helper_path(new_path, new_helper_path, ".finf/", false);
415 +        create_helper_dir(new_path, ".finf/");
416 +        rename(old_helper_path, new_helper_path);
417 +        make_helper_path(old_path, old_helper_path, ".rsrc/", false);
418 +        make_helper_path(new_path, new_helper_path, ".rsrc/", false);
419 +        create_helper_dir(new_path, ".rsrc/");
420 +        rename(old_helper_path, new_helper_path);
421 +
422 +        // Now rename file
423 +        return rename(old_path, new_path) == 0;
424 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines