Skip to content

Commit 73bc5a7

Browse files
committed
chore: Rename file utility functions with cloudsync prefix
Renamed file_delete, file_read, and file_write (and related static helpers) to cloudsync_file_delete, cloudsync_file_read, and cloudsync_file_write for improved clarity and namespace consistency. Updated all usages in cloudsync.c and utils.c/h accordingly.
1 parent 021f80d commit 73bc5a7

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/cloudsync.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ void cloudsync_payload_save (sqlite3_context *context, int argc, sqlite3_value *
23442344

23452345
// retrieve full path to file
23462346
const char *path = (const char *)sqlite3_value_text(argv[0]);
2347-
file_delete(path);
2347+
cloudsync_file_delete(path);
23482348

23492349
// retrieve payload
23502350
char *blob = NULL;
@@ -2357,7 +2357,7 @@ void cloudsync_payload_save (sqlite3_context *context, int argc, sqlite3_value *
23572357
if (blob == NULL || blob_size == 0) return;
23582358

23592359
// write payload to file
2360-
bool res = file_write(path, blob, (size_t)blob_size);
2360+
bool res = cloudsync_file_write(path, blob, (size_t)blob_size);
23612361
sqlite3_free(blob);
23622362

23632363
if (res == false) {
@@ -2394,7 +2394,7 @@ void cloudsync_payload_load (sqlite3_context *context, int argc, sqlite3_value *
23942394
const char *path = (const char *)sqlite3_value_text(argv[0]);
23952395

23962396
sqlite3_int64 payload_size = 0;
2397-
char *payload = file_read(path, &payload_size);
2397+
char *payload = cloudsync_file_read(path, &payload_size);
23982398
if (!payload) {
23992399
if (payload_size == -1) sqlite3_result_error(context, "Unable to read payload from file path.", -1);
24002400
if (payload) cloudsync_memory_free(payload);

src/utils.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,15 @@ uint64_t fnv1a_hash (const char *data, size_t len) {
295295

296296
#ifdef CLOUDSYNC_DESKTOP_OS
297297

298-
bool file_delete (const char *path) {
298+
bool cloudsync_file_delete (const char *path) {
299299
#ifdef _WIN32
300300
return DeleteFileA(path);
301301
#else
302302
return (unlink(path) == 0);
303303
#endif
304304
}
305305

306-
static bool file_read_all (int fd, char *buf, size_t n) {
306+
static bool cloudsync_file_read_all (int fd, char *buf, size_t n) {
307307
size_t off = 0;
308308
while (off < n) {
309309
#ifdef _WIN32
@@ -322,7 +322,7 @@ static bool file_read_all (int fd, char *buf, size_t n) {
322322
return true;
323323
}
324324

325-
char *file_read (const char *path, sqlite3_int64 *len) {
325+
char *cloudsync_file_read (const char *path, sqlite3_int64 *len) {
326326
int fd = -1;
327327
char *buffer = NULL;
328328

@@ -352,7 +352,7 @@ char *file_read (const char *path, sqlite3_int64 *len) {
352352
if (!buffer) goto abort_read;
353353
buffer[sz] = '\0';
354354

355-
if (!file_read_all(fd, buffer, sz)) goto abort_read;
355+
if (!cloudsync_file_read_all(fd, buffer, sz)) goto abort_read;
356356
if (len) *len = sz;
357357

358358
file_close(fd);
@@ -366,7 +366,7 @@ char *file_read (const char *path, sqlite3_int64 *len) {
366366
return NULL;
367367
}
368368

369-
int file_create (const char *path) {
369+
int cloudsync_file_create (const char *path) {
370370
#ifdef _WIN32
371371
int flags = _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY;
372372
int mode = _S_IWRITE; // Windows ignores most POSIX perms
@@ -378,7 +378,7 @@ int file_create (const char *path) {
378378
#endif
379379
}
380380

381-
static bool file_write_all (int fd, const char *buf, size_t n) {
381+
static bool cloudsync_file_write_all (int fd, const char *buf, size_t n) {
382382
size_t off = 0;
383383
while (off < n) {
384384
#ifdef _WIN32
@@ -397,11 +397,11 @@ static bool file_write_all (int fd, const char *buf, size_t n) {
397397
return true;
398398
}
399399

400-
bool file_write (const char *path, const char *buffer, size_t len) {
401-
int fd = file_create(path);
400+
bool cloudsync_file_write (const char *path, const char *buffer, size_t len) {
401+
int fd = cloudsync_file_create(path);
402402
if (fd < 0) return false;
403403

404-
bool res = file_write_all(fd, buffer, len);
404+
bool res = cloudsync_file_write_all(fd, buffer, len);
405405

406406
file_close(fd);
407407
return res;

src/utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ void cloudsync_rowid_decode (sqlite3_int64 rowid, sqlite3_int64 *db_version, sql
150150

151151
// available only on Desktop OS
152152
#ifdef CLOUDSYNC_DESKTOP_OS
153-
bool file_delete (const char *path);
154-
char *file_read (const char *path, sqlite3_int64 *len);
155-
bool file_write (const char *path, const char *buffer, size_t len);
153+
bool cloudsync_file_delete (const char *path);
154+
char *cloudsync_file_read (const char *path, sqlite3_int64 *len);
155+
bool cloudsync_file_write (const char *path, const char *buffer, size_t len);
156156
#endif
157157

158158
#endif

0 commit comments

Comments
 (0)