static int repo_init_structure(repo_init *results) { const int mode = 0755; /* or 0777 ? */ char temp_path[GIT_PATH_MAX]; char *git_dir = results->path_repository; if (gitfo_mkdir_recurs(git_dir, mode)) return GIT_ERROR; /* Creates the '/objects/info/' directory */ git__joinpath(temp_path, git_dir, GIT_OBJECTS_INFO_DIR); if (gitfo_mkdir_recurs(temp_path, mode) < GIT_SUCCESS) return GIT_ERROR; /* Creates the '/objects/pack/' directory */ git__joinpath(temp_path, git_dir, GIT_OBJECTS_PACK_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/heads/' directory */ git__joinpath(temp_path, git_dir, GIT_REFS_HEADS_DIR); if (gitfo_mkdir_recurs(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/tags/' directory */ git__joinpath(temp_path, git_dir, GIT_REFS_TAGS_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; /* TODO: what's left? templates? */ return GIT_SUCCESS; }
static int repo_init_structure(repo_init *results) { const int mode = 0755; /* or 0777 ? */ char temp_path[GIT_PATH_MAX]; int path_len; char *git_dir = results->path_repository; if (gitfo_mkdir_recurs(git_dir, mode)) return GIT_ERROR; path_len = strlen(git_dir); strcpy(temp_path, git_dir); /* Does HEAD file already exist ? */ strcpy(temp_path + path_len, GIT_HEAD_FILE); if (gitfo_exists(temp_path) == GIT_SUCCESS) return repo_init_reinit(results); if (repo_init_createhead(temp_path) < GIT_SUCCESS) return GIT_ERROR; /* Creates the '/objects/info/' directory */ strcpy(temp_path + path_len, GIT_OBJECTS_INFO_DIR); if (gitfo_mkdir_recurs(temp_path, mode)) return GIT_ERROR; /* Creates the '/objects/pack/' directory */ strcpy(temp_path + path_len, GIT_OBJECTS_PACK_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/heads/' directory */ strcpy(temp_path + path_len, GIT_REFS_HEADS_DIR); if (gitfo_mkdir_recurs(temp_path, mode)) return GIT_ERROR; /* Creates the '/refs/tags/' directory */ strcpy(temp_path + path_len, GIT_REFS_TAGS_DIR); if (gitfo_mkdir(temp_path, mode)) return GIT_ERROR; /* TODO: what's left? templates? */ return GIT_SUCCESS; }
int gitfo_mv_force(const char *from, const char *to) { const int mode = 0755; /* or 0777 ? */ int error = GIT_SUCCESS; char target_folder_path[GIT_PATH_MAX]; error = git__dirname_r(target_folder_path, sizeof(target_folder_path), to); if (error < GIT_SUCCESS) return error; /* Does the containing folder exist? */ if (gitfo_isdir(target_folder_path)) { git__joinpath(target_folder_path, target_folder_path, ""); /* Ensure there's a trailing slash */ /* Let's create the tree structure */ error = gitfo_mkdir_recurs(target_folder_path, mode); if (error < GIT_SUCCESS) return error; } return gitfo_mv(from, to); }