modified cache_create

This commit is contained in:
Fufu Fang 2019-04-22 02:59:53 +01:00
parent 212e319f20
commit 07b8382022
2 changed files with 17 additions and 16 deletions

View File

@ -139,7 +139,7 @@ static Cache **CACHE_OPENED;
/**
* \brief The number of opened cache files
*/
static int N_CACHE_OPENED;
static int N_CACHE_OPENED = 0;
void CacheSystem_init(const char *path)
{
@ -512,7 +512,7 @@ static int Cache_exist(const char *fn)
return !(meta_exists & data_exists);
}
Cache *Cache_create(const char *fn, long len, long time)
int Cache_create(const char *fn, long len, long time)
{
Cache *cf = Cache_alloc();
@ -521,17 +521,16 @@ Cache *Cache_create(const char *fn, long len, long time)
cf->content_length = len;
if (Data_create(cf)) {
Cache_free(cf);
fprintf(stderr, "Cache_create(): Data_create() failed!\n");
return NULL;
}
if (Meta_create(cf)) {
Cache_free(cf);
fprintf(stderr, "Cache_create(): Meta_create() failed!\n");
return NULL;
}
return cf;
Cache_free(cf);
return Cache_exist(fn);
}
static void Cache_delete(const char *fn)

View File

@ -52,17 +52,14 @@ typedef struct {
*/
void CacheSystem_init(const char *dir);
/**
* \brief open a cache file set
* \note Call this when FUSE opens a file
*/
Cache *Cache_open(const char *fn);
/**
* \brief create a cache file set
* * \return
* - 0, if the cache file was created succesfully
* - -1, otherwise
* \note Call this when creating a new LinkTable
*/
Cache *Cache_create(const char *fn, long len, long time);
int Cache_create(const char *fn, long len, long time);
/**
* \brief Create directories under the cache directory structure, if they do
@ -75,6 +72,13 @@ Cache *Cache_create(const char *fn, long len, long time);
*/
int CacheDir_create(const char *fn);
/***************************** Work in Progress ******************************/
/**
* \brief open a cache file set
* \note Call this when FUSE opens a file
*/
Cache *Cache_open(const char *fn);
/**
* \brief Check if a segment exists.
* \note Call this when deciding whether to download a file
@ -89,8 +93,6 @@ int Seg_exist(Cache *cf, long start);
*/
void Seg_set(Cache *cf, long start, int i);
/***************************** To be completed ******************************/
/**