This commit is contained in:
anon
2025-01-24 22:57:46 +01:00
parent a2a5aacf63
commit 42922b74c0
8 changed files with 344 additions and 60 deletions

View File

@ -14,10 +14,35 @@ extern mode_t char_to_mode_type(const char c);
extern char * mode_to_str(mode_t mode, char * buffer);
extern mode_t str_to_mode(const char *permissions);
extern int (*mytouch)(const char *filename);
extern int (*mydelete)(const char *filename);
extern int (*mychmod)(const char *filename, mode_t mode);
extern int (*mychown)(const char *filename, const char *owner, const char *group);
extern int (*mymove)(const char *filename, const char *newname);
extern int (*mytouch)(const char * filename);
extern int (*mydelete)(const char * filename);
extern int (*mychmod)(const char * filename, mode_t mode);
extern int (*mychown)(const char * filename, const char * owner, const char * group);
extern int (*mymove)(const char * filename, const char * newname);
extern int (*mycopy)(const char * filename, const char * newname);
/* Swapping file names is only possible with an intermediate rename,
* and it also means that we can't headlessly replace files.
* For this reason we buffer failing renames until
* the rest of the file operations are completed.
* However, we have the following concerns:
* 1) we don't want to move the file out of its directory,
* so that in case of an error,
* its not lost *somewhere* on the filesystem
* 2) a simple and predictable name is preferable,
* because if an error is encountered,
* we want the user to easily recognize his files
* 3) the temp name might already be taken
* Points 1 and 2 cause 3 to exists.
* To deal with 3, we use the tactic employed by the original vidir:
* + we try incrementing suffixes until something works or we get bored
*/
typedef struct {
char * orig_name;
char * curt_name;
char * dest_name;
} move_data_t;
extern move_data_t (*mytempmove)(const char * filename, const char * newname);
#endif