2016-10-27 18:11:34 +00:00
|
|
|
/***
|
|
|
|
* handles a repo on the file system
|
|
|
|
*/
|
|
|
|
#ifndef fs_repo_h
|
|
|
|
#define fs_repo_h
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2016-11-03 04:05:29 +00:00
|
|
|
#include "ipfs/repo/config/config.h"
|
|
|
|
|
2016-10-27 18:11:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* a structure to hold the repo info
|
|
|
|
*/
|
|
|
|
struct FSRepo {
|
|
|
|
int closed;
|
|
|
|
char* path;
|
|
|
|
struct IOCloser* lock_file;
|
2016-11-17 20:07:59 +00:00
|
|
|
struct RepoConfig* config;
|
2016-10-27 18:11:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* opens a fsrepo
|
2016-11-30 16:46:41 +00:00
|
|
|
* @param repo the repo struct. Should contain the path. This method will do the rest
|
2016-10-27 18:11:34 +00:00
|
|
|
* @return 0 if there was a problem, otherwise 1
|
|
|
|
*/
|
2016-11-17 20:07:59 +00:00
|
|
|
int ipfs_repo_fsrepo_open(struct FSRepo* repo);
|
2016-10-27 18:11:34 +00:00
|
|
|
|
2016-10-31 16:13:42 +00:00
|
|
|
/***
|
|
|
|
* checks to see if the repo is initialized
|
|
|
|
* @param repo_path the path to the repo
|
|
|
|
* @returns true(1) if it is initialized, otherwise false(0)
|
|
|
|
*/
|
|
|
|
int fs_repo_is_initialized(char* repo_path);
|
2016-10-27 18:11:34 +00:00
|
|
|
|
2016-11-03 04:05:29 +00:00
|
|
|
/**
|
|
|
|
* write the config file to disk
|
|
|
|
* @param path the path to the file
|
|
|
|
* @param config the config structure
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int fs_repo_write_config_file(char* path, struct RepoConfig* config);
|
|
|
|
|
2016-11-10 13:28:51 +00:00
|
|
|
/**
|
2016-11-30 16:46:41 +00:00
|
|
|
* constructs the FSRepo struct.
|
|
|
|
* Remember: ipfs_repo_fsrepo_free must be called
|
|
|
|
* @param repo_path the path to the repo
|
|
|
|
* @param config the optional config file. NOTE: if passed, fsrepo_free will free resources of the RepoConfig.
|
|
|
|
* @param repo the struct to allocate memory for
|
|
|
|
* @returns false(0) if something bad happened, otherwise true(1)
|
2016-11-10 13:28:51 +00:00
|
|
|
*/
|
2016-12-05 22:23:58 +00:00
|
|
|
int ipfs_repo_fsrepo_new(const char* repo_path, struct RepoConfig* config, struct FSRepo** fs_repo);
|
2016-11-10 13:28:51 +00:00
|
|
|
|
2016-11-17 20:07:59 +00:00
|
|
|
/***
|
|
|
|
* Free all resources used by this struct
|
|
|
|
* @param repo the repo to clean up
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int ipfs_repo_fsrepo_free(struct FSRepo* config);
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Initialize a new repo with the specified configuration
|
|
|
|
* @param config the information in order to build the repo
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int ipfs_repo_fsrepo_init(struct FSRepo* config);
|
2016-11-03 04:05:29 +00:00
|
|
|
|
2016-10-27 18:11:34 +00:00
|
|
|
#endif /* fs_repo_h */
|