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

Comparing BasiliskII/src/AmigaOS/extfs_amiga.cpp (file contents):
Revision 1.2 by cebix, 1999-11-08T16:43:10Z vs.
Revision 1.4 by cebix, 1999-11-08T18:05:57Z

# Line 366 | Line 366 | size_t extfs_write(int fd, void *buffer,
366  
367  
368   /*
369 + *  Remove file/directory (and associated helper files),
370 + *  returns false on error (and sets errno)
371 + */
372 +
373 + bool extfs_remove(const char *path)
374 + {
375 +        // Remove helpers first, don't complain if this fails
376 +        char helper_path[MAX_PATH_LENGTH];
377 +        make_helper_path(path, helper_path, ".finf/", false);
378 +        remove(helper_path);
379 +        make_helper_path(path, helper_path, ".rsrc/", false);
380 +        remove(helper_path);
381 +
382 +        // Now remove file or directory (and helper directories in the directory)
383 +        if (remove(path) < 0) {
384 +                if (errno == EISDIR || errno == ENOTEMPTY) {
385 +                        helper_path[0] = 0;
386 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
387 +                        add_path_component(helper_path, ".finf");
388 +                        rmdir(helper_path);
389 +                        helper_path[0] = 0;
390 +                        strncpy(helper_path, path, MAX_PATH_LENGTH-1);
391 +                        add_path_component(helper_path, ".rsrc");
392 +                        rmdir(helper_path);
393 +                        return rmdir(path) == 0;
394 +                } else
395 +                        return false;
396 +        }
397 +        return true;
398 + }
399 +
400 +
401 + /*
402 + *  Rename/move file/directory (and associated helper files),
403 + *  returns false on error (and sets errno)
404 + */
405 +
406 + bool extfs_rename(const char *old_path, const char *new_path)
407 + {
408 +        // Rename helpers first, don't complain if this fails
409 +        char old_helper_path[MAX_PATH_LENGTH], new_helper_path[MAX_PATH_LENGTH];
410 +        make_helper_path(old_path, old_helper_path, ".finf/", false);
411 +        make_helper_path(new_path, new_helper_path, ".finf/", false);
412 +        create_helper_dir(new_path, ".finf/");
413 +        rename(old_helper_path, new_helper_path);
414 +        make_helper_path(old_path, old_helper_path, ".rsrc/", false);
415 +        make_helper_path(new_path, new_helper_path, ".rsrc/", false);
416 +        create_helper_dir(new_path, ".rsrc/");
417 +        rename(old_helper_path, new_helper_path);
418 +
419 +        // Now rename file
420 +        return rename(old_path, new_path) == 0;
421 + }
422 +
423 +
424 + /*
425   *  ftruncate() is missing from libnix
426   */
427  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines