示例#1
0
static bs_file_t  __hlfs_file_open(struct back_storage *storage,const char*path,int flags){
	//HLOG_DEBUG("hdfs -- enter func %s", __func__);
    char full_path[256];
    build_hdfs_path(full_path,storage->dir,storage->fs_name,path);
    //HLOG_DEBUG("hdfs full path %s",full_path);
    hdfsFile file = NULL;
    file =  hdfsOpenFile((hdfsFS)storage->fs_handler,full_path,flags, 0, 0, 0);
    if(NULL == file){
	   //HLOG_DEBUG("hdfsOpenFile error");
       return NULL;
    }
    //HLOG_DEBUG("hdfs file:%p",file);
	//HLOG_DEBUG("hdfs -- leave func %s", __func__);
    return (bs_file_t)file;
}
示例#2
0
int hdfs_file_mkdir(struct back_storage *storage, const char *dir_path){
	//HLOG_DEBUG("hdfs -- enter func %s", __func__);
	char full_path[256];
	build_hdfs_path(full_path, storage->dir, storage->fs_name, dir_path);
	//HLOG_DEBUG("hdfs mkdir:%s",full_path);
	if (0 == hdfsExists((hdfsFS)storage->fs_handler, full_path)) {
		return -1;
	}
	if (0 != hdfsCreateDirectory((hdfsFS)storage->fs_handler, full_path)) {
		//HLOG_DEBUG("hdfsCreateDirectory error");
		return -1;
	}
	//HLOG_DEBUG("hdfs -- leave func %s", __func__);
	return 0;
}
示例#3
0
bs_file_info_t * 
hdfs_file_info(struct back_storage *storage,const char* path){
	//HLOG_DEBUG("hdfs -- enter func %s", __func__);
    char full_path[256];
    build_hdfs_path(full_path,storage->dir,storage->fs_name,path);
    hdfsFileInfo *hinfo = hdfsGetPathInfo((hdfsFS)storage->fs_handler,full_path);
    if(NULL == hinfo){
	   //HLOG_ERROR("hdfsGetPathInfo error");
       return NULL;
    }
    bs_file_info_t *info = (bs_file_info_t*)g_malloc0(sizeof(bs_file_info_t));
    if (NULL == info) {
	    //HLOG_ERROR("Allocate Error!");
	    return NULL;
    }
    strcpy((char *) info->name, (const char *) hinfo->mName);
    info->is_dir = 0;//?
    info->size = hinfo->mSize;
    info->lmtime = hinfo->mLastMod;
    free(hinfo);
	//HLOG_DEBUG("hdfs -- leave func %s", __func__);
    return info;
}