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


C++ FilePath::getExtension方法代码示例

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


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

示例1: parse

bool Chain::parse (const ssi_char_t *filepath) {

	release ();

	if (filepath == 0 || filepath[0] == '\0') {
		ssi_wrn ("file is empty");
		return false;
	}

	FilePath fp (filepath);
	ssi_char_t *filepath_with_ext = 0;
	if (strcmp (fp.getExtension (), SSI_FILE_TYPE_CHAIN) != 0) {
		filepath_with_ext = ssi_strcat (filepath, SSI_FILE_TYPE_CHAIN);
	} else {
		filepath_with_ext = ssi_strcpy (filepath);
	}

	if (!ssi_exists (filepath_with_ext)) {
		ssi_wrn ("file not found '%s", filepath_with_ext);
		return false;
	}

	ssi_msg (SSI_LOG_LEVEL_BASIC, "load '%s'", filepath_with_ext);

	TiXmlDocument doc;
	if (!doc.LoadFile (filepath_with_ext)) {
		ssi_wrn ("failed loading chain from file '%s'", filepath_with_ext);
		delete[] filepath_with_ext;
		return false;
	}

	TiXmlElement *body = doc.FirstChildElement();	
	if (!body || strcmp (body->Value (), "chain") != 0) {
		ssi_wrn ("tag <chain> missing");
		delete[] filepath_with_ext;
		return false;	
	}

	TiXmlElement *filter = body->FirstChildElement ("filter");
	if (filter) {
		if (!parseFilter (filter)) {
			ssi_wrn ("failed parsing <filter> tag");
			return false;
		}
	}

	TiXmlElement *feature = body->FirstChildElement ("feature");
	if (feature) {
		if (!parseFeature (feature)) {
			ssi_wrn ("failed parsing <feature> tag");
			return false;
		}
	}

	_parsed = feature || filter;
	if (!_parsed) {
		ssi_wrn ("parsing failed because no feature/filter were loaded");
	}

	return _parsed;
}
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:61,代码来源:Chain.cpp

示例2: main

int main (int argc, char **argv) {

#ifdef USE_SSI_LEAK_DETECTOR
	{
#endif

	char info[1024];
	ssi_sprint (info, "\n%s\n\nbuild version: %s\n\n", SSI_COPYRIGHT, SSI_VERSION);

	//**** READ COMMAND LINE ****//

	CmdArgParser cmd;
	cmd.info (info);

	ssi_char_t *dllpath = 0;	
	ssi_char_t *apipath = 0;	
	ssi_char_t *outdir = 0;
	ssi_char_t *reg = 0; 
	bool index;

	cmd.addText("\nArguments:");
	cmd.addSCmdArg("dllpath", &dllpath, "input path to dll");	

	cmd.addText ("\nOptions:");
	cmd.addSCmdOption ("-dir", &outdir, "", "output directory []");
	cmd.addBCmdOption ("-index", &index, false, "create index [false]");
	cmd.addSCmdOption ("-reg", &reg, "", "register additional dll's (if several separate by semicolon)");
	
	if (cmd.read (argc, argv)) {		

		ssi_char_t string[SSI_MAX_CHAR];

		FilePath fp (dllpath);
		ssi_char_t *dllpath_with_ext = 0;
		if (strcmp (fp.getExtension (), ".dll") != 0) {
			dllpath_with_ext = ssi_strcat (dllpath, ".dll");
		} else {
			dllpath_with_ext = ssi_strcpy (dllpath);
		}

		if (Factory::RegisterDLL (dllpath_with_ext)) {	

			// register additional dlls
			if (reg) {
				APIGenerator::SaveCurrentComponentList ();
				ssi_size_t n_reg = ssi_split_string_count (reg, ';');
				ssi_char_t **regs = new ssi_char_t *[n_reg];
				ssi_split_string (n_reg, regs, reg, ';');
				for (ssi_size_t i = 0; i < n_reg; i++) {
					Factory::RegisterDLL (regs[i]);
					delete[] regs[i];
				}
				delete[] regs;
			}

			if (outdir[0] == '\0') {
				ssi_sprint (string, "%s", fp.getPath ());
			} else {
				ssi_sprint (string, "%s\\%s", outdir, fp.getName ());
			}

			APIGenerator::CreateAPI (string);
			APIGenerator::ResetCurrentComponentList ();
			Factory::Clear ();
		}

		if (index) {
			if (outdir[0] == '\0') {
				APIGenerator::CreateAPIIndex (fp.getDir ());
			} else {
				APIGenerator::CreateAPIIndex (outdir);
			}
		}

		delete[] dllpath_with_ext;
	}

	delete[] dllpath;	
	delete[] apipath;	
	delete[] outdir;

#ifdef USE_SSI_LEAK_DETECTOR
	}
	_CrtDumpMemoryLeaks();
#endif

	return 0;
}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:88,代码来源:Main.cpp

示例3: open

bool FileSamplesOut::open (ISamples &data,
	const ssi_char_t *path,
	File::TYPE type, 
	File::VERSION version) {

	ssi_msg (SSI_LOG_LEVEL_DETAIL, "open files '%s'", path);	

	_version = version;

	if (_version < File::V2) {
		ssi_wrn ("version < V2 not supported");
		return false;
	}

	if (_file_info || _file_data) {
		ssi_wrn ("samples already open");
		return false;
	}

	_n_users = data.getUserSize ();
	_users = new ssi_char_t *[_n_users];
	_n_per_user = new ssi_size_t[_n_users];
	for (ssi_size_t i = 0; i < _n_users; i++) {
		_users[i] = ssi_strcpy (data.getUserName (i));
		_n_per_user[i] = 0;
	}
	_n_classes = data.getClassSize ();
	_classes = new ssi_char_t *[_n_classes];
	_n_per_class = new ssi_size_t[_n_classes];
	for (ssi_size_t i = 0; i < _n_classes; i++) {
		_classes[i] = ssi_strcpy (data.getClassName (i));
		_n_per_class[i] = 0;
	}
	
	_n_streams = data.getStreamSize ();
	_streams = new ssi_stream_t[_n_streams];
	for (ssi_size_t i = 0; i < _n_streams; i++) {
		ssi_stream_t s = data.getStream (i);
		ssi_stream_init (_streams[i], 0, s.dim, s.byte, s.type, s.sr, 0);
	}

	_has_missing_data = false;

	if (path == 0 || path[0] == '\0') {
		_console = true;
	}

	if (_console) {
		
		_file_data = File::CreateAndOpen (type, File::WRITE, "");
		if (!_file_data) {
			ssi_wrn ("could not open console");
			return false;
		}

	} else {

		FilePath fp (path);
		ssi_char_t *path_info = 0;
		if (strcmp (fp.getExtension (), SSI_FILE_TYPE_SAMPLES) != 0) {
			path_info = ssi_strcat (path, SSI_FILE_TYPE_SAMPLES);
		} else {
			path_info = ssi_strcpy (path);
		}	
		_path = ssi_strcpy (path_info);

		_file_info = File::CreateAndOpen (File::ASCII, File::WRITE, path_info);
		if (!_file_info) {
			ssi_wrn ("could not open info file '%s'", path_info);
			return false;
		}

		ssi_sprint (_string, "<?xml version=\"1.0\" ?>\n<samples ssi-v=\"%d\">", version);
		_file_info->writeLine (_string);
	
		ssi_char_t *path_data = ssi_strcat (path_info, "~");			
		_file_data = File::CreateAndOpen (type, File::WRITE, path_data);
		if (!_file_data) {
			ssi_wrn ("could not open data file '%s'", path_data);
			return false;
		}

		if (_version == File::V3) {

			_file_streams = new FileStreamOut[_n_streams];
			ssi_char_t string[SSI_MAX_CHAR];
			for (ssi_size_t i = 0; i < _n_streams; i++) {
				ssi_sprint (string, "%s.#%u", path_info, i);
				_file_streams[i].open (_streams[i], string, type);				
			}

		}

		delete[] path_info;
		delete[] path_data;

	}

	return true;
};
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:100,代码来源:FileSamplesOut.cpp

示例4: open

bool FileStreamIn::open (ssi_stream_t &data,
	const ssi_char_t *path,
	ssi_size_t &n_meta,
	void **meta) {

	ssi_msg (SSI_LOG_LEVEL_DETAIL, "open stream file '%s'", path);	

	if (_file_info || _file_data) {
		ssi_wrn ("stream already open");
		return false;
	}

	if (path == 0 || path[0] == '\0') {
		ssi_wrn ("'%s' is not a valid path", path);
		return false;
	}

	FilePath fp (path);
	ssi_char_t *path_info = 0;
	if (strcmp (fp.getExtension (), SSI_FILE_TYPE_STREAM) != 0) {
		path_info = ssi_strcat (path, SSI_FILE_TYPE_STREAM);
	} else {
		path_info = ssi_strcpy (path);
	}	
	_path = ssi_strcpy (path_info);

	_file_info = File::CreateAndOpen (File::ASCII, File::READ, path_info);
	if (!_file_info) {
		ssi_wrn ("could not open info file '%s'", path_info);
		return false;
	}

	TiXmlDocument doc;
	if (!doc.LoadFile (_file_info->getFile ())) {
		ssi_wrn ("failed loading stream from file '%s'", path_info);
		return false;
	}

	TiXmlElement *body = doc.FirstChildElement();	
	if (!body || strcmp (body->Value (), "stream") != 0) {
		ssi_wrn ("tag <stream> missing");
		return false;	
	}

	int v = 0;
	if (body->QueryIntAttribute ("ssi-v", &v) != TIXML_SUCCESS) {
		ssi_wrn ("attribute <ssi-v> in tag <stream> missing");
		return false;	
	}
	_version = ssi_cast (File::VERSION, v);

	if (_version < File::V2) {
		ssi_wrn ("version < V2 not supported");
		return false;
	}
	
	TiXmlElement *element = body->FirstChildElement ("info");
	if (!element || strcmp (element->Value (), "info") != 0) {
		ssi_wrn ("tag <info> missing");
		return false;
	}

	ssi_time_t sample_rate = 0;
	if (element->QueryDoubleAttribute ("sr", &sample_rate) != TIXML_SUCCESS) {
		ssi_wrn ("attribute <sr> missing in tag <info>");
		return false;
	}

	int sample_dimension = 0;
	if (element->QueryIntAttribute ("dim", &sample_dimension) != TIXML_SUCCESS) {
		ssi_wrn ("attribute <dim> missing in tag <info>");
		return false;
	}

	int sample_byte = 0;
	if (element->QueryIntAttribute ("byte", &sample_byte) != TIXML_SUCCESS) {
		ssi_wrn ("attribute <byte> missing in tag <info>");
		return false;
	}

	const char *type = element->Attribute ("type");
	if (!type) {
		ssi_wrn ("attribute <type> missing in tag <info>");
		return false;
	}
	ssi_type_t sample_type;
	if (!ssi_name2type (type, sample_type)) {
		ssi_wrn ("could not parse type from '%s'", type);
		return false;
	}

	const char *ftype_name = element->Attribute ("ftype");
	if (!ftype_name) {
		ssi_wrn ("attribute <ftype> missing in tag <info>");
		return false;
	}
	File::TYPE ftype;
	if (strcmp (ftype_name, File::TYPE_NAMES[0]) == 0) {
		ftype = File::BINARY;
	} else if (strcmp (ftype_name, File::TYPE_NAMES[1]) == 0) {
//.........这里部分代码省略.........
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:101,代码来源:FileStreamIn.cpp


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