refactor: merge File/FileReceive, add optional metadata transfer with -M flag
- Remove FileReceive struct; use File everywhere with nullable FileMetadata* - Remove struct stat from File; file size lives in Data->size (data_create_reserve) - Add FileMetadata struct (mode, uid, gid, mtime) sent conditionally over wire - Add -M / --preserve flag to client - Restore permissions, ownership, timestamps on disk write - Wire format uses per-file present flag for metadata (zero overhead when off)
This commit is contained in:
+12
-9
@@ -5,24 +5,27 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
typedef struct {
|
||||
char *path;
|
||||
struct stat stats;
|
||||
Data *data;
|
||||
} File;
|
||||
mode_t mode;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
time_t mtime_sec;
|
||||
long mtime_nsec;
|
||||
} FileMetadata;
|
||||
|
||||
typedef struct {
|
||||
char *path;
|
||||
Data *data;
|
||||
} FileReceive;
|
||||
FileMetadata *metadata;
|
||||
} File;
|
||||
|
||||
File *file_create(const char *path, struct stat *stats);
|
||||
File *file_create(const char *path);
|
||||
void file_destroy(void *item);
|
||||
void file_load_data(File *file);
|
||||
void file_print(void *item);
|
||||
void file_send_single_calls(File *file, int file_descriptor);
|
||||
size_t file_content_to_buffer(File *file);
|
||||
|
||||
FileReceive *file_receive_create(char *path, Data *data);
|
||||
void file_receive_destroy(void *file_receive);
|
||||
FileMetadata *file_metadata_create(struct stat *stats);
|
||||
void file_metadata_destroy(void *metadata);
|
||||
FileMetadata *file_receive_metadata(int file_descriptor);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user