コード例 #1
0
ファイル: OssFS.cpp プロジェクト: dluobo/cloudfs
int OssFS::mkdir(const char *path, mode_t mode) 
{
	log_debug("path:%s", path);
	std::vector<OssStats *> dir_stats;
	string tmp_str = path;
    if (tmp_str.at(tmp_str.length() - 1) != '/') {
        tmp_str.append("/");
    }

	OssDirObject* parentObj = (OssDirObject *)get_parent(path);
	if (NULL == parentObj)
	{
		log_error("path [%s]", path);
		return -ENOENT;
	}
	OssObject *obj = this->add_file(tmp_str.c_str(), dir_stats, OSS_DIR);
	if (NULL == obj)
	{
		return -ENOENT;
	}

	OSS_FILE_META meta;
	obj->get_stats()->to_meta(meta);
    m_oss->put_object_data(AliConf::BUCKET.c_str(), obj->get_path_name(), meta);


	return 0;
}
コード例 #2
0
ファイル: OssFS.cpp プロジェクト: dluobo/cloudfs
int OssFS::del_file(const char *path) 
{
	if (strcmp(path, "/") == 0) 
	{
		return -ENOENT;
	} 

	OssObject *obj = find_certain_path(path);
	if (obj == NULL)
	{
		return -ENOENT;
	}
	
	//先删除OSS对象
	obj->delete_oss_object();

	//删除meta_db中的记录
	string tmpPath = obj->get_path_name();
	cloudfs_sqlite_remove_file_meta(tmpPath);

	//删除父目录中的记录
	OssDirObject *parent_dir = (OssDirObject *)get_parent(path);
	if (parent_dir != NULL)
	{		
		parent_dir->remove_record(obj->get_file_name());
	}

	return 0;

}