update: finish up the pull command

This commit is contained in:
ngn
2024-05-02 23:20:33 +03:00
parent d7e347175f
commit 9e8f57c175
10 changed files with 98 additions and 41 deletions

View File

@ -111,7 +111,7 @@ bool mksubdirsp(char *path, int perms) {
for (char *c = path; *c != '\0'; c++) {
if (*c == '/' && indx != 0) {
cur[indx] = '\0';
if (!exists(cur) && mkdir(cur, perms) < 0){
if (!exists(cur) && mkdir(cur, perms) < 0) {
error_set(_("Failed to create directory: %s"), cur);
errno = MkdirFail;
return false;
@ -122,7 +122,7 @@ bool mksubdirsp(char *path, int perms) {
indx++;
}
if (!exists(cur) && mkdir(cur, perms) < 0){
if (!exists(cur) && mkdir(cur, perms) < 0) {
error_set(_("Failed to create directory: %s"), cur);
errno = MkdirFail;
return false;
@ -196,12 +196,12 @@ void clist_add(clist_t *l, char *en) {
l->s++;
}
bool copyfile(char *src, char *dst){
bool copyfile(char *src, char *dst) {
FILE *srcf = fopen(src, "r");
FILE *dstf = fopen(dst, "w");
if(NULL == srcf || NULL == dstf){
if(NULL == srcf)
if (NULL == srcf || NULL == dstf) {
if (NULL == srcf)
error_set(_("Failed to open \"%s\" for reading"), srcf);
else
error_set(_("Failed to open \"%s\" for writing"), dstf);
@ -210,11 +210,11 @@ bool copyfile(char *src, char *dst){
}
char buffer[32];
int read = -1;
int read = -1;
bzero(buffer, 32);
while((read = fread(buffer, 1, 32, srcf)) > 0)
while ((read = fread(buffer, 1, 32, srcf)) > 0)
fwrite(buffer, 1, read, dstf);
fclose(srcf);