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


C++ FileSpecifier类代码示例

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


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

示例1: CopyContents

// Copy file contents
bool FileSpecifier::CopyContents(FileSpecifier &source_name)
{
	err = 0;
	OpenedFile src, dst;
	if (source_name.Open(src)) {
		Delete();
		if (Open(dst, true)) {
			const int BUFFER_SIZE = 1024;
			uint8 buffer[BUFFER_SIZE];

			int32 length = 0;
			src.GetLength(length);

			while (length && err == 0) {
				int32 count = length > BUFFER_SIZE ? BUFFER_SIZE : length;
				if (src.Read(count, buffer)) {
					if (!dst.Write(count, buffer))
						err = dst.GetError();
				} else
					err = src.GetError();
				length -= count;
			}
		}
	} else
		err = source_name.GetError();
	if (err)
		Delete();
	return err == 0;
}
开发者ID:logue,项目名称:alephone_jp,代码行数:30,代码来源:FileHandler.cpp

示例2: save_cache

void WadImageCache::save_cache()
{
	if (!m_cache_dirty)
		return;
	
	InfoTree pt;
	
	for (cache_iter_t it = m_used.begin(); it != m_used.end(); ++it)
	{
		std::string name = it->second.first;
		WadImageDescriptor desc = boost::tuples::get<0>(it->first);
		
		pt.put(name + ".path", desc.file.GetPath());
		pt.put(name + ".checksum", desc.checksum);
		pt.put(name + ".index", desc.index);
		pt.put(name + ".tag", desc.tag);
		pt.put(name + ".width", boost::tuples::get<1>(it->first));
		pt.put(name + ".height", boost::tuples::get<2>(it->first));
		pt.put(name + ".filesize", it->second.second);
	}
	
	FileSpecifier info;
	info.SetToImageCacheDir();
	info.AddPart("Cache.ini");
	try {
		pt.save_ini(info);
		m_cache_dirty = false;
	} catch (InfoTree::ini_error e) {
		logError("Could not save image cache to %s (%s)", info.GetPath(), e.what());
		return;
	}
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:32,代码来源:WadImageCache.cpp

示例3: confirm_save_choice

static bool confirm_save_choice(FileSpecifier & file)
{
	// If the file doesn't exist, everything is alright
	if (!file.Exists())
		return true;

	// Construct message
	char name[256];
	file.GetName(name);
	char message[512];
	sprintf(message, "'%s' already exists.", name);

	// Create dialog
	dialog d;
	vertical_placer *placer = new vertical_placer;
	placer->dual_add(new w_static_text(message), d);
	placer->dual_add(new w_static_text("Ok to overwrite?"), d);
	placer->add(new w_spacer(), true);

	horizontal_placer *button_placer = new horizontal_placer;
	w_button *default_button = new w_button("YES", dialog_ok, &d);
	button_placer->dual_add(default_button, d);
	button_placer->dual_add(new w_button("NO", dialog_cancel, &d), d);

	placer->add(button_placer, true);

	d.activate_widget(default_button);

	d.set_widget_placer(placer);

	// Run dialog
	return d.run() == 0;
}
开发者ID:logue,项目名称:alephone_jp,代码行数:33,代码来源:FileHandler.cpp

示例4: operator

	void operator() (const std::string& arg) const {
		if (!NetAllowSavingLevel())
		{
			screen_printf("Level saving disabled");
			return;
		}

		std::string filename = arg;
		if (filename == "")
		{
			if (last_level != "")
				filename = last_level;
			else
			{
				filename = mac_roman_to_utf8(static_world->level_name);
				if (!boost::algorithm::ends_with(filename, ".sceA"))
					filename += ".sceA";
			}
		}
		else
		{
			if (!boost::algorithm::ends_with(filename, ".sceA"))
				filename += ".sceA";	
		}

		last_level = filename;
		FileSpecifier fs;
		fs.SetToLocalDataDir();
		fs += filename;
		if (export_level(fs))
			screen_printf("Saved %s", utf8_to_mac_roman(fs.GetPath()).c_str());
		else
			screen_printf("An error occurred while saving the level");
	}
开发者ID:Aleph-One-Marathon,项目名称:alephone-psp,代码行数:34,代码来源:Console.cpp

示例5: ParseFile

bool XML_Loader_SDL::ParseFile(FileSpecifier &file_name)
{
  // Open file
  OpenedFile file;
  if (file_name.Open(file)) {
    printf ( "Parsing: %s\n", file_name.GetPath() );
    // Get file size and allocate buffer
    file.GetLength(data_size);
    data = new char[data_size];

    // In case there were errors...
    file_name.GetName(FileName);

    // Read and parse file
    if (file.Read(data_size, data)) {
      if (!DoParse()) {
        fprintf(stderr, "There were parsing errors in configuration file %s\n",
                FileName);
      }
    }

    // Delete buffer
    delete[] data;
    data = NULL;
    return true;
  } else {
    printf ( "Couldn't open: %s\n", file_name.GetPath() );
  }
  return false;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例6: save_game

bool save_game(
    void)
{
    pause_game();
    show_cursor();

    /* Translate the name, and display the dialog */
    FileSpecifier SaveFile;
    get_current_saved_game_name(SaveFile);
    char GameName[256];
    SaveFile.GetName(GameName);

    char Prompt[256];
    // Must allow the sound to play in the background
    bool success = SaveFile.WriteDialogAsync(
                       _typecode_savegame,
                       getcstr(Prompt, strPROMPTS, _save_game_prompt),
                       GameName);

    if (success)
        success = save_game_file(SaveFile);

    hide_cursor();
    resume_game();

    return success;
}
开发者ID:Aleph-One-Marathon,项目名称:alephone-dingoo,代码行数:27,代码来源:preprocess_map_mac.cpp

示例7: get

SDL_Surface* QuickSaveImageCache::get(std::string image_name) {
    std::map<std::string, cache_iter_t>::iterator it = m_images.find(image_name);
    if (it != m_images.end()) {
        // found it: move to front of list
        m_used.splice(m_used.begin(), m_used, it->second);
        return it->second->second;
    }
    
    // didn't find: load image
    FileSpecifier f;
    f.SetToQuickSavesDir();
	f.AddPart(image_name + ".sgaA");
	
	WadImageDescriptor desc;
	desc.file = f;
	desc.checksum = 0;
	desc.index = SAVE_GAME_METADATA_INDEX;
	desc.tag = SAVE_IMG_TAG;
	
	SDL_Surface *img = WadImageCache::instance()->get_image(desc, PREVIEW_WIDTH, PREVIEW_HEIGHT);
	if (img) {
        m_used.push_front(cache_pair_t(image_name, img));
        m_images[image_name] = m_used.begin();
        
        // enforce maximum cache size
        if (m_used.size() > k_max_items) {
            cache_iter_t lru = m_used.end();
            --lru;
            m_images.erase(lru->first);
            SDL_FreeSurface(lru->second);
            m_used.pop_back();
        }
    }
    return img;
}
开发者ID:pfhore-github,项目名称:alephone_jp,代码行数:35,代码来源:QuickSave.cpp

示例8: printf

bool XML_Loader_SDL::ParseDirectory(FileSpecifier &dir)
{
  // Get sorted list of files in directory
  printf ( "Looking in %s\n", dir.GetPath() );
  vector<dir_entry> de;
  if (!dir.ReadDirectory(de)) {
    return false;
  }
  sort(de.begin(), de.end());

  // Parse each file
  vector<dir_entry>::const_iterator i, end = de.end();
  for (i=de.begin(); i!=end; i++) {
    if (i->is_directory) {
      continue;
    }
    if (i->name[i->name.length() - 1] == '~') {
      continue;
    }
    // people stick Lua scripts in Scripts/
    if (boost::algorithm::ends_with(i->name, ".lua")) {
      continue;
    }

    // Construct full path name
    FileSpecifier file_name = dir + i->name;

    // Parse file
    ParseFile(file_name);
  }

  return true;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例9: sort

bool FileFinder::Find(DirectorySpecifier &dir, Typecode type, bool recursive)
{
	// Get list of entries in directory
	vector<dir_entry> entries;
	if (!dir.ReadDirectory(entries))
		return false;
	sort(entries.begin(), entries.end());

	// Iterate through entries
	vector<dir_entry>::const_iterator i, end = entries.end();
	for (i = entries.begin(); i != end; i++) {

		// Construct full specifier of file/dir
		FileSpecifier file = dir + i->name;

		if (i->is_directory) {

			// Recurse into directory
			if (recursive)
				if (Find(file, type, recursive))
					return true;

		} else {

			// Check file type and call found() function
			if (type == WILDCARD_TYPE || type == file.GetType())
				if (found(file))
					return true;
		}
	}
	return false;
}
开发者ID:Aleph-One-Marathon,项目名称:alephone-dingoo,代码行数:32,代码来源:find_files_sdl.cpp

示例10: ParsePlugin

bool PluginLoader::ParsePlugin(FileSpecifier& file_name)
{
  OpenedFile file;
  if (file_name.Open(file)) {
    int32 data_size;
    file.GetLength(data_size);
    m_data.resize(data_size);

    if (file.Read(data_size, &m_data[0])) {
      file_name.ToDirectory(current_plugin_directory);

      char name[256];
      current_plugin_directory.GetName(name);
      m_name = name;

      if (!DoParse()) {
        logError1("There were parsing errors in %s Plugin.xml\n", m_name.c_str());
      }
    }

    m_data.clear();
    return true;
  }
  return false;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例11: LoadModel_Studio

bool LoadModel_Studio(FileSpecifier& Spec, Model3D& Model)
{
	ModelPtr = &Model;
	Model.Clear();
	
	if (DBOut)
	{
		// Name buffer
		const int BufferSize = 256;
		char Buffer[BufferSize];
		Spec.GetName(Buffer);
		fprintf(DBOut,"Loading 3D Studio Max model file %s\n",Buffer);
	}
	
	OpenedFile OFile;
	if (!Spec.Open(OFile))
	{	
		if (DBOut) fprintf(DBOut,"ERROR opening the file\n");
		return false;
	}
	
	ChunkHeaderData ChunkHeader;
	if (!ReadChunkHeader(OFile,ChunkHeader)) return false;
	if (ChunkHeader.ID != MASTER)
	{
		if (DBOut) fprintf(DBOut,"ERROR: not a 3DS Max model file\n");
		return false;
	}
	
	if (!ReadContainer(OFile,ChunkHeader,ReadMaster)) return false;
	
	return (!Model.Positions.empty() && !Model.VertIndices.empty());
}
开发者ID:Aleph-One-Marathon,项目名称:alephone-dingoo,代码行数:33,代码来源:StudioLoader.cpp

示例12: delete_storage_for_name

void WadImageCache::delete_storage_for_name(std::string& name) const
{
	FileSpecifier file;
	file.SetToImageCacheDir();
	file.AddPart(name);
	file.Delete();
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:7,代码来源:WadImageCache.cpp

示例13: Start

bool OGL_LoadScreen::Start()
{
	// load the image
	FileSpecifier File;
	if (path.size() == 0) return use = false;
	if (!File.SetNameWithPath(path.c_str())) return use = false;
	if (!image.LoadFromFile(File, ImageLoader_Colors, 0)) return use = false;

	if (!blitter.Load(image)) return use = false;

	int screenWidth, screenHeight;
	MainScreenSize(screenWidth, screenHeight);
	bound_screen();
	
	// the true width/height
	int imageWidth = static_cast<int>(image.GetWidth() * image.GetVScale());
	int imageHeight = static_cast<int>(image.GetHeight() * image.GetUScale());

	if (scale)
	{
		if (stretch)
		{
			m_dst.w = screenWidth;
			m_dst.h = screenHeight;
		}
		else if (imageWidth / imageHeight > screenWidth / screenHeight) 
		{
			m_dst.w = screenWidth;
			m_dst.h = imageHeight * screenWidth / imageWidth;
		} 
		else 
		{
			m_dst.w = imageWidth * screenHeight / imageHeight;
			m_dst.h = screenHeight;
		}
	}
	else
	{
		m_dst.w = imageWidth;
		m_dst.h = imageHeight;
	}
	m_dst.x = (screenWidth - m_dst.w) / 2;
	m_dst.y = (screenHeight - m_dst.h) / 2;
	
	x_offset = m_dst.x;
	y_offset = m_dst.y;
	x_scale = m_dst.w / (double) imageWidth;
	y_scale = m_dst.h / (double) imageHeight;
						  
	OGL_ClearScreen();
	
	Progress(0);

	return use = true;
}
开发者ID:PyroXFire,项目名称:alephone,代码行数:55,代码来源:OGL_LoadScreen.cpp

示例14: load_mmls

static void load_mmls(const Plugin& plugin, XML_Loader_SDL& loader)
{
  ScopedSearchPath ssp(plugin.directory);
  for (std::vector<std::string>::const_iterator it = plugin.mmls.begin();
       it != plugin.mmls.end(); ++it)
  {
    FileSpecifier file;
    file.SetNameWithPath(it->c_str());
    loader.ParseFile(file);
  }
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例15:

static const char *locate_font(const std::string& path)
{
	builtin_fonts_t::iterator j = builtin_fonts.find(path);
	if (j != builtin_fonts.end() || path == "")
	{
		return path.c_str();
	}
	else
	{
		static FileSpecifier file;
		if (file.SetNameWithPath(path.c_str()))
			return file.GetPath();
		else
			return "";
	}
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:16,代码来源:sdl_fonts.cpp


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