当前位置: 首页>>代码示例>>C++>>正文


C++ FileSystem类代码示例

本文整理汇总了C++中FileSystem的典型用法代码示例。如果您正苦于以下问题:C++ FileSystem类的具体用法?C++ FileSystem怎么用?C++ FileSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add_load

int MainMenu::add_load(char *new_path)
{
	char filename[BCTEXTLEN];
	FileSystem dir;

	int total_loads = recent_load->items.total;

	if(total_loads == 0)
	{
		filemenu->add_item(new BC_MenuItem("-"));
	}

	int new_total = recent_load->add_item(NULL, new_path);

	if (new_total > total_loads) {
		// just create a new item if there is room for it
		int i = new_total - 1;
		load[i] = new LoadPrevious(mwindow);
		dir.extract_name(filename, new_path, 0);
		load[i]->set_text(filename);
		load[i]->set_path(new_path);
		filemenu->add_item(load[i]);
	}

	// reassign the paths to adjust for the shift down
	for(int i = 0; i < new_total; i++) {
		char *path = recent_load->items.values[i]->get_text();
		dir.extract_name(filename, path, 0);
		load[i]->set_text(filename);
		load[i]->set_path(path);
	}

	return 0;
}
开发者ID:rasilon,项目名称:cinelerra-cv,代码行数:34,代码来源:mainmenu.C

示例2: Setup

    void AtomicGlowApp::Setup()
    {
        IPCClientApp::Setup();

        // AtomicGlow is always headless
        engineParameters_["Headless"] = true;

        FileSystem* filesystem = GetSubsystem<FileSystem>();
        engineParameters_.InsertNew("LogName", filesystem->GetAppPreferencesDir("AtomicEditor", "Logs") + "AtomicGlow.log");

        ToolSystem* tsystem = new ToolSystem(context_);
        context_->RegisterSubsystem(tsystem);

        ToolEnvironment* env = new ToolEnvironment(context_);
        context_->RegisterSubsystem(env);

        String projectPath;

        for (unsigned i = 0; i < arguments_.Size(); ++i)
        {
            if (arguments_[i].Length() > 1)
            {
                String argument = arguments_[i].ToLower();
                String value = i + 1 < arguments_.Size() ? arguments_[i + 1] : String::EMPTY;

                if (argument == "--project" && value.Length())
                {
                    if (GetExtension(value) == ".atomic")
                    {
                        value = GetPath(value);
                    }

                    if (filesystem->DirExists(value))
                    {

                    }
                    else
                    {
                        ErrorExit(ToString("%s project path does not exist", value.CString()));
                    }

                    projectPath = AddTrailingSlash(value);

                }
            }
        }

        if (!env->Initialize())
        {

			ErrorExit("Unable to initialize tool environment from %s");

            return;
        }

        engineParameters_["ResourcePrefixPaths"] = env->GetRootSourceDir() + "/Resources/";
        engineParameters_["ResourcePaths"] = ToString("CoreData;EditorData;%sResources;%sCache", projectPath.CString(), projectPath.CString());


    }
开发者ID:dragonCASTjosh,项目名称:AtomicGameEngine,代码行数:60,代码来源:AtomicGlowApp.cpp

示例3: get_new_vnode

static status_t
get_new_vnode(fs_volume* volume, ino_t id, VnodeToInode** _vti)
{
	FileSystem* fs = reinterpret_cast<FileSystem*>(volume->private_volume);
	Inode* inode;
	VnodeToInode* vti;

	status_t result = acquire_vnode(volume, id);
	if (result == B_OK) {
		ASSERT(get_vnode(volume, id, reinterpret_cast<void**>(_vti)) == B_OK);
		unremove_vnode(volume, id);

		// Release after acquire
		put_vnode(volume, id);

		vti = *_vti;

		if (vti->Get() == NULL) {
			result = fs->GetInode(id, &inode);
			if (result != B_OK) {
				put_vnode(volume, id);
				return result;
			}

			vti->Replace(inode);
		}
		return B_OK;
	}

	return get_vnode(volume, id, reinterpret_cast<void**>(_vti));
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例4: SplitPath

bool CubemapGenerator::InitPaths()
{

    String scenePath = sceneEditor_->GetFullPath();

    String pathName;
    String fileName;
    String ext;

    SplitPath(scenePath, pathName, fileName, ext);

    outputPathAbsolute_ = pathName + "Cubemaps/" + fileName + "/";

    FileSystem* fileSystem = GetSubsystem<FileSystem>();

    if (!fileSystem->DirExists(outputPathAbsolute_))
    {
        if (!fileSystem->CreateDirs(pathName,  "Cubemaps/" + fileName + "/"))
        {
            LOGERRORF("CubemapGenerator::InitRender - Unable to create path: %s", outputPathAbsolute_.CString());
            return false;
        }
    }

    // TODO: There should be a better way of getting the resource path
    ToolSystem* tsystem = GetSubsystem<ToolSystem>();
    Project* project = tsystem->GetProject();

    resourcePath_ = outputPathAbsolute_;
    resourcePath_.Replace(project->GetResourcePath(), "");
    resourcePath_ = AddTrailingSlash(resourcePath_);

    return true;

}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:35,代码来源:CubemapGenerator.cpp

示例5: init_shapes

void ShapeWipeMain::init_shapes()
{
	if(!shapes_initialized)
	{
		FileSystem fs;
		fs.set_filter("*.png");
		char shape_path[BCTEXTLEN];
		sprintf(shape_path, "%s%s", get_plugin_dir(), SHAPE_SEARCHPATH);
		fs.update(shape_path);

		for(int i = 0; i < fs.total_files(); i++)
		{
			FileItem *file_item = fs.get_entry(i);
			if(!file_item->get_is_dir())
			{
				shape_paths.append(strdup(file_item->get_path()));
				char *ptr = strdup(file_item->get_name());
				char *ptr2 = strrchr(ptr, '.');
				if(ptr2) *ptr2 = 0;
				shape_titles.append(ptr);
			}
		}

		shapes_initialized = 1;
	}
}
开发者ID:petterreinholdtsen,项目名称:cinelerra-hv,代码行数:26,代码来源:shapewipe.C

示例6: start_progress

void Render::start_progress()
{
	char filename[BCTEXTLEN];
	char string[BCTEXTLEN];
	FileSystem fs;

	progress_max = Units::to_int64(default_asset->sample_rate * 
			(total_end - total_start)) +
		Units::to_int64(preferences->render_preroll * 
			packages->total_allocated * 
			default_asset->sample_rate);
	progress_timer->update();
	last_eta = 0;
	if(mwindow)
	{
// Generate the progress box
		fs.extract_name(filename, default_asset->path);
		sprintf(string, _("Rendering %s..."), filename);

// Don't bother with the filename since renderfarm defeats the meaning
		progress = mwindow->mainprogress->start_progress(_("Rendering..."), 
			progress_max);
		render_progress = new RenderProgress(mwindow, this);
		render_progress->start();
	}
}
开发者ID:petterreinholdtsen,项目名称:cinelerra-hv,代码行数:26,代码来源:render.C

示例7:

bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError)
{

    Editor* editor = GetSubsystem<Editor>();
    Project* project = editor->GetProject();

    String fullpath = resourcePath + resourceName;
    if (!resourceName.EndsWith(".tmx"))
        fullpath += ".tmx";

    FileSystem* fs = GetSubsystem<FileSystem>();

    if (fs->FileExists(fullpath))
    {
        if (reportError)
        {
            String errorMsg;
            errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString());
            editor->PostModalError("Create 2D Level Error", errorMsg);
        }

        return false;
    }

    return true;

}
开发者ID:gitter-badger,项目名称:Clockwork,代码行数:27,代码来源:CEResourceOps.cpp

示例8: strlen

int IndexFile::get_index_filename(char *source_filename, 
	char *index_directory, 
	char *index_filename, 
	char *input_filename)
{
// Replace slashes and dots
	int i, j;
	int len = strlen(input_filename);
	for(i = 0, j = 0; i < len; i++)
	{
		if(input_filename[i] != '/' &&
			input_filename[i] != '.')
			source_filename[j++] = input_filename[i];
		else
		{
			if(i > 0)
				source_filename[j++] = '_';
		}
	}
	source_filename[j] = 0;
	FileSystem fs;
	fs.join_names(index_filename, index_directory, source_filename);
	strcat(index_filename, ".idx");
	return 0;
}
开发者ID:beequ7et,项目名称:cinelerra-cv,代码行数:25,代码来源:indexfile.C

示例9: Object

LicenseSystem::LicenseSystem(Context* context) :
    Object(context)
    , eulaAgreementConfirmed_(false)

{
    FileSystem* filesystem = GetSubsystem<FileSystem>();

    licenseFilePath_ = filesystem->GetAppPreferencesDir("AtomicEditor", "License");
    licenseFilePath_ = AddTrailingSlash(licenseFilePath_);

    if (!filesystem->DirExists(licenseFilePath_))
    {
        Poco::File dirs(licenseFilePath_.CString());
        dirs.createDirectories();
    }

    licenseCachePath_ = licenseFilePath_;

    licenseCachePath_ += "AtomicLicenseCache";

    licenseFilePath_ += "AtomicLicense";

    eulaAgreementPath_ = filesystem->GetAppPreferencesDir("AtomicEditor", "License");
    eulaAgreementPath_ = AddTrailingSlash(eulaAgreementPath_);
    eulaAgreementPath_ += "EulaConfirmed";

    ResetLicense();
}
开发者ID:EternalXY,项目名称:AtomicGameEngine,代码行数:28,代码来源:LicenseSystem.cpp

示例10: GetPreferencesPath

 String AEEditorPrefs::GetPreferencesPath()
 {
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     String path = fileSystem->GetAppPreferencesDir("AtomicEditor", "Preferences");
     path += "prefs.json";
     return path;
 }
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:7,代码来源:AEEditorPrefs.cpp

示例11: LoadPreferences

    bool AEEditorPrefs::LoadPreferences(JSONValue& prefs)
    {
        FileSystem* fileSystem = GetSubsystem<FileSystem>();
        String path = GetPreferencesPath();

        if (!fileSystem->FileExists(path))
        {
            if (!CreateDefaultPreferences(path, prefs))
                return false;
        }
        else
        {
            SharedPtr<File> file(new File(context_, path, FILE_READ));
            SharedPtr<JSONFile> jsonFile(new JSONFile(context_));

            if (!jsonFile->BeginLoad(*file))
            {
                file->Close();
                if (!CreateDefaultPreferences(path, prefs))
                    return false;
            }
            else
            {
                prefs = jsonFile->GetRoot();
            }

            file->Close();
        }

        return true;
    }
开发者ID:LumaDigital,项目名称:AtomicGameEngine,代码行数:31,代码来源:AEEditorPrefs.cpp

示例12: RefreshFromFile

        //--------------------------------------------------------------
        //--------------------------------------------------------------
		void AppDataStore::RefreshFromFile()
        {
            FileSystem* pFileSystem = Application::Get()->GetFileSystem();
            if(pFileSystem->DoesFileExist(StorageLocation::k_saveData, k_filename) == true)
            {
				FileStreamSPtr fileStream = pFileSystem->CreateFileStream(StorageLocation::k_saveData, k_filename, FileMode::k_readBinary);
				if (fileStream != nullptr)
                {
					fileStream->SeekG(0, SeekDir::k_end);
					u32 encryptedDataSize = fileStream->TellG();
					fileStream->SeekG(0, SeekDir::k_beginning);
                    
                    std::unique_ptr<s8[]> encryptedData(new s8[encryptedDataSize]);
					fileStream->Read(encryptedData.get(), encryptedDataSize);
					fileStream.reset();
                    
                    std::string decrypted = AESEncrypt::DecryptString(reinterpret_cast<const u8*>(encryptedData.get()), encryptedDataSize, k_privateKey);

                    XMLUPtr xml = XMLUtils::ParseDocument(decrypted);
                    XML::Node* root = XMLUtils::GetFirstChildElement(xml->GetDocument());
                    if(nullptr != root)
                    {
                        m_dictionary = ParamDictionarySerialiser::FromXml(root);
                    }
                }
            }
            
            m_needsSynchonised = false;
        }
开发者ID:DNSMorgan,项目名称:ChilliSource,代码行数:31,代码来源:AppDataStore.cpp

示例13: lock

        //--------------------------------------------------------------
        //--------------------------------------------------------------
		void AppDataStore::Save()
        {
            std::unique_lock<std::mutex> lock(m_mutex);
            
			if(m_needsSynchonised == true)
            {
                // Convert to XML
                XML::Document doc;
                XML::Node* rootNode = doc.allocate_node(rapidxml::node_type::node_element);
                doc.append_node(rootNode);
                ParamDictionarySerialiser::ToXml(m_dictionary, rootNode);
                
                // Encrypt
                std::string strDocToBeEncrypted = XMLUtils::ToString(&doc);
                AESEncrypt::Data encryptedData = AESEncrypt::EncryptString(strDocToBeEncrypted, k_privateKey);

                // Write to disk
                FileSystem* pFileSystem = Application::Get()->GetFileSystem();
                FileStreamSPtr pFileStream = pFileSystem->CreateFileStream(StorageLocation::k_saveData, k_filename, FileMode::k_writeBinary);
                if(pFileStream != nullptr)
                {
                    pFileStream->Write(reinterpret_cast<const s8*>(encryptedData.m_data.get()), encryptedData.m_size);
                    pFileStream.reset();
                }
                
                m_needsSynchonised = false;
            }
		}
开发者ID:DNSMorgan,项目名称:ChilliSource,代码行数:30,代码来源:AppDataStore.cpp

示例14: readMetadata

bool DirFile::readMetadata()
{
	FileSystem* filesys = FileSystem::get_instance();
	FileSystem::FileList files;

	/*int ret =*/ filesys->ListFiles(path + "*", files);

	// TODO: check if directory actually exists

	count = files.size();

	FileSystem::FileList::iterator iter;

	for (iter = files.begin(); iter != files.end(); ++iter) {
		std::string name = *iter;
		std::string::size_type pos = name.rfind("/");
		if (pos != std::string::npos) {
			name.erase(0, pos+1);
			pout << "DirFile: " << name << std::endl;
			storeIndexedName(name);
		}
	}

	return true;
}
开发者ID:amichaelt,项目名称:pentagram,代码行数:25,代码来源:DirFile.cpp

示例15: if

void FileStreamTfs::open()
{
    try{
        if (m_openMode == FileStream::ReadOnly){
            if (m_fin != NULL) return;
            m_fin = new InputStream;
            m_fin->open(m_filename.c_str(), 0);
            //cout <<"FileStreamTfs opens " <<m_filename <<" for read " <<endl;
        }
        else if (m_openMode == FileStream::Append){
            //cout <<"FileStreamTfs opens " <<m_filename <<" for append " <<endl;
            if (m_fout != NULL) return;

            FileSystem fs;
            if (!fs.existFile(m_filename)){
                fs.createFile(m_filename, 1, 0);
            }

            m_fout = new AppendStream;
            m_fout->open(m_filename.c_str(), 0);
        }
    }
    catch (tfs::api::TFSException& e){
        throw FSError(string("FileStreamTfs open file failed :") + m_filename + " error=>" + e.what());
    }
}
开发者ID:kyhhdm,项目名称:TPlatform,代码行数:26,代码来源:FileStreamTfs.cpp


注:本文中的FileSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。