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


C++ GetFileLength函数代码示例

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


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

示例1: init_path

static void init_path(char *argv0, char *path_specified)
{//=====================================================

	if(path_specified)
	{
		sprintf(path_home,"%s/espeak-data",path_specified);
		return;
	}

#ifdef PLATFORM_WINDOWS
	HKEY RegKey;
	unsigned long size;
	unsigned long var_type;
	char *p;
	char *env;
	unsigned char buf[sizeof(path_home)-12];

	if(((env = getenv("ESPEAK_DATA_PATH")) != NULL) && ((strlen(env)+12) < sizeof(path_home)))
	{
		sprintf(path_home,"%s\\espeak-data",env);
		if(GetFileLength(path_home) == -2)
			return;   // an espeak-data directory exists in the directory specified by environment variable
	}

	strcpy(path_home,argv0);
	if((p = strrchr(path_home,'\\')) != NULL)
	{
		strcpy(&p[1],"espeak-data");
		if(GetFileLength(path_home) == -2)
			return;   // an espeak-data directory exists in the same directory as the espeak program
	}

	// otherwise, look in the Windows Registry
	buf[0] = 0;
	RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak", 0, KEY_READ, &RegKey);
	size = sizeof(buf);
	var_type = REG_SZ;
	RegQueryValueEx(RegKey, "path", 0, &var_type, buf, &size);

	sprintf(path_home,"%s\\espeak-data",buf);
#else
#ifdef PLATFORM_DOS
		strcpy(path_home,PATH_ESPEAK_DATA);
#else
	char *env;
	if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
	{
		snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
		if(GetFileLength(path_home) == -2)
			return;   // an espeak-data directory exists 
	}

	snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
	if(access(path_home,R_OK) != 0)
	{
		strcpy(path_home,PATH_ESPEAK_DATA);
	}
#endif
#endif
}
开发者ID:MobileAppCodes,项目名称:espeak,代码行数:60,代码来源:speak.cpp

示例2: init_path

static void init_path(const char *path)
{//====================================
#ifdef PLATFORM_WINDOWS
	HKEY RegKey;
	unsigned long size;
	unsigned long var_type;
	char *env;
	unsigned char buf[sizeof(path_home)-13];

	if(path != NULL)
	{
		sprintf(path_home,"%s/espeak-data",path);
		return;
	}

	if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
	{
		sprintf(path_home,"%s/espeak-data",env);
		if(GetFileLength(path_home) == -2)
			return;   // an espeak-data directory exists 
	}
	
#if defined (PATH_ESPEAK_DATA)
	sprintf(path_home,"%s/espeak-data",PATH_ESPEAK_DATA);
	if (GetFileLength(path_home) == -2)
		return;		// espeak-data is a valid directory
#endif

	buf[0] = 0;
	RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak", 0, KEY_READ, &RegKey);
	size = sizeof(buf);
	var_type = REG_SZ;
	RegQueryValueExA(RegKey, "path", 0, &var_type, buf, &size);

	sprintf(path_home,"%s\\espeak-data",buf);

#else
	char *env;

	if(path != NULL)
	{
		snprintf(path_home,sizeof(path_home),"%s/espeak-data",path);
		return;
	}

	// check for environment variable
	if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
	{
		snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
		if(GetFileLength(path_home) == -2)
			return;   // an espeak-data directory exists 
	}

	snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
	if(access(path_home,R_OK) != 0)
	{
		strcpy(path_home,PATH_ESPEAK_DATA);
	}
#endif
}
开发者ID:North2,项目名称:Oolite,代码行数:60,代码来源:speak_lib.cpp

示例3: check_data_path

static int check_data_path(const char *path, int allow_directory)
{
	if (!path) return 0;

	snprintf(path_home, sizeof(path_home), "%s/espeak-ng-data", path);
	if (GetFileLength(path_home) == -EISDIR)
		return 1;

	if (!allow_directory)
		return 0;

	snprintf(path_home, sizeof(path_home), "%s", path);
	return GetFileLength(path_home) == -EISDIR;
}
开发者ID:rhdunn,项目名称:espeak,代码行数:14,代码来源:speech.c

示例4: file

bool MD5Model::LoadModel( const std::string &filename )
{
    if ( !fs::exists(filename) )
    {
        std::cerr << "MD5Model::LoadModel: Failed to find file: " << filename << std::endl;
        return false;
    }

    fs::path filePath = filename;
    // store the parent path used for loading images relative to this file.
    fs::path parent_path = filePath.parent_path();

    std::string param;
    std::string junk;   // Read junk from the file

    fs::ifstream file(filename);
    int fileLength = GetFileLength( file );
    assert( fileLength > 0 );

    m_Joints.clear();
    m_Meshes.clear();

    file >> param;

    while ( !file.eof() )
    {
        if ( param == "MD5Version" )
        {
            file >> m_iMD5Version;
            assert( m_iMD5Version == 10 );
        }
        else if ( param == "commandline" )
开发者ID:rinrynque,项目名称:md5,代码行数:32,代码来源:MD5Model.cpp

示例5: MultiByteToWideChar

static wad_file_t *W_Win32_OpenFile(char *path)
{
    win32_wad_file_t    *result;
    wchar_t             wpath[MAX_PATH + 1];
    HANDLE              handle;

    // Open the file:
    MultiByteToWideChar(CP_OEMCP, 0, path, strlen(path) + 1, wpath, sizeof(wpath));

    handle = CreateFileW(wpath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL, NULL);

    if (handle == INVALID_HANDLE_VALUE)
        return NULL;

    // Create a new win32_wad_file_t to hold the file handle.
    result = Z_Malloc(sizeof(win32_wad_file_t), PU_STATIC, NULL);
    result->wad.file_class = &win32_wad_file;
    result->wad.length = GetFileLength(handle);
    result->handle = handle;

    // Try to map the file into memory with mmap:
    MapFile(result);

    return &result->wad;
}
开发者ID:Manuel-K,项目名称:doomretro,代码行数:26,代码来源:w_file_win32.c

示例6: ReadPhFile

static espeak_ng_STATUS ReadPhFile(void **ptr, const char *fname, int *size, espeak_ng_ERROR_CONTEXT *context)
{
	if (!ptr) return EINVAL;

	FILE *f_in;
	unsigned int length;
	char buf[sizeof(path_home)+40];

	sprintf(buf, "%s%c%s", path_home, PATHSEP, fname);
	length = GetFileLength(buf);

	if ((f_in = fopen(buf, "rb")) == NULL)
		return create_file_error_context(context, errno, buf);

	if (*ptr != NULL)
		Free(*ptr);

	if ((*ptr = Alloc(length)) == NULL) {
		fclose(f_in);
		return ENOMEM;
	}
	if (fread(*ptr, 1, length, f_in) != length) {
		int error = errno;
		fclose(f_in);
		Free(*ptr);
		return create_file_error_context(context, error, buf);
	}

	fclose(f_in);
	if (size != NULL)
		*size = length;
	return ENS_OK;
}
开发者ID:JamaicanUser,项目名称:espeak-ng,代码行数:33,代码来源:synthdata.c

示例7: open

static wad_file_t *W_POSIX_OpenFile(char *path)
{
    posix_wad_file_t *result;
    int handle;

    handle = open(path, 0);

    if (handle < 0)
    {
        return NULL;
    }

    // Create a new posix_wad_file_t to hold the file handle.

    result = Z_Malloc(sizeof(posix_wad_file_t), PU_STATIC, 0);
    result->wad.file_class = &posix_wad_file;
    result->wad.length = GetFileLength(handle);
    result->handle = handle;

    // Try to map the file into memory with mmap:

    MapFile(result, path);

    return &result->wad;
}
开发者ID:Clever-Boy,项目名称:chocolate-doom,代码行数:25,代码来源:w_file_posix.c

示例8: LoadShaderSource

int LoadShaderSource(const char* filename, GLchar** source, unsigned long* len)
{
   FILE *file;
   unsigned int i=0;
   GLchar *txt;
   unsigned long size;

   file = fopen(filename, "rb"); // opens as Binary
   if(!file) 
	   return -1;
   *len = GetFileLength(file);
   fclose(file);
   if(*len <= 0)
	   return -2;
   size = *len;
   file = fopen(filename, "r"); //Opens as ASCII
   *source = (GLchar*)malloc(sizeof(GLchar)*(*len));
   txt = *source;
   if (*source == 0) return -3;   // can't reserve memory
   
    // len isn't always strlen cause some characters are stripped in ascii read...
    // it is important to 0-terminate the real length later, len is just max possible value... 
   txt[size-1] = 0; 

   
   while ((txt[i] = fgetc(file)) != EOF)
        i++;
    
   txt[i] = 0;  // 0-terminate it at the correct position
   fclose(file);
      
   return 0; // No Error
}
开发者ID:superkehoed,项目名称:midterm,代码行数:33,代码来源:shader.c

示例9: LoadTextFileToExistingBuffer

///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
bool LoadTextFileToExistingBuffer( const std::string& filePath, char* existingBuffer, const size_t& existingBufferSize )
{
    FILE* file;
    fopen_s( &file, filePath.c_str(), "rb" );

    if (!file)
    {
        // freak out
        return false;
    }

    size_t numBytes = GetFileLength( file );

    if (numBytes > existingBufferSize)
        return false;

    size_t numberOfElementsRead = fread( existingBuffer, sizeof( char ), existingBufferSize - 1, file );
    fclose( file );

    existingBuffer[numberOfElementsRead] = '\0';

    // buffer is bigger than data read
    if (numberOfElementsRead < numBytes)
        return false; 

    return true;

}
开发者ID:tbgeorge,项目名称:putty_engine,代码行数:31,代码来源:FileUtilities.cpp

示例10: CreateHostRunDir

void Ide::BuildAndDebug0(const String& srcfile)
{
	if(Build()) {
		One<Host> h = CreateHostRunDir();
		h->ChDir(GetFileFolder(target));
		VectorMap<String, String> bm = GetMethodVars(method);
		String dbg = bm.Get("DEBUGGER", Null);
		if(IsNull(dbg)) {
			if(bm.Get("BUILDER", Null) == "MSC71") {
				String sln = ForceExt(target, ".sln");
				if(GetFileLength(sln) > 0)
					h->Launch("devenv \"" + h->GetHostPath(sln) + "\" "
					// + "\"" + h->GetHostPath(srcfile) + "\"" //TRC, 2011/09/26: wrong devenv argument
					);
				else
					h->Launch("devenv \"" + h->GetHostPath(target)
					//+ "\" \"" + h->GetHostPath(srcfile) //TRC, 2011/09/26: wrong devenv argument
					+ "\" /debugexe "
					);
				return;
			}
			dbg = "gdb";
		}
		else
			h->Launch('\"' + dbg + "\" \""
//			          + h->GetHostPath(srcfile) + ' '
			          + h->GetHostPath(target) + "\"", true);
	}
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:29,代码来源:Debug.cpp

示例11: LoadHZData

int LoadHZData(const TCHAR *hz_data_name)
{
	int file_length;

	assert(hz_data_name);

	if (share_segment->hz_data_loaded)
		return 1;

	file_length = GetFileLength(hz_data_name);
	if (file_length <= 0)
		return 0;

	hz_data = AllocateSharedMemory(hz_data_share_name, file_length);
	if (!hz_data)
		return 0;

	if ((file_length = LoadFromFile(hz_data_name, hz_data, file_length)) == -1)
	{
		FreeSharedMemory(hz_data_share_name, hz_data);
		Log(LOG_ID, L"汉字信息表文件打开失败。name=%s", hz_data_name);
		return 0;
	}

	if (!file_length)
		return 0;

	share_segment->hz_data_loaded = 1;

	return 1;
}
开发者ID:709889989,项目名称:unispim,代码行数:31,代码来源:zi.c

示例12: main

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

	for (i = 1; i < argc; i++) {
		size_t filesize = GetFileLength(argv[i]);
		FILE *stream = fopen(argv[i], "r");
		unsigned char *text = NULL;
		if (stream == NULL) {
			perror(argv[i]);
			exit(EXIT_FAILURE);
		}

		text = (unsigned char *) malloc(filesize + 1);
		if (text == NULL) {
			espeak_ng_PrintStatusCodeMessage(ENOMEM, stderr, NULL);
			exit(EXIT_FAILURE);
		}

		fread(text, 1, filesize, stream);
		text[filesize] = 0;
		fclose(stream);

		LLVMFuzzerTestOneInput(text, filesize);
		free(text);
	}

	return EXIT_SUCCESS;
}
开发者ID:rhdunn,项目名称:espeak,代码行数:28,代码来源:fuzzrunner.c

示例13: DisplayErrorFile

void DisplayErrorFile(const char *fname)
{//=====================================
	int len;
	FILE *f;
	char *msg;
	wxString msg_string;

	len = GetFileLength(fname);
	if(len > 0)
	{
		if(len > 1500)
			len = 1500;   // restrict length to prevent crash in wxLogMessage()
		msg = (char *)malloc(len+1);
		if(msg != NULL)
		{
			f = fopen(fname,"r");
			len = fread(msg,1, len, f);
			fclose(f);
			msg[len] = 0;
			msg_string = wxString(msg,wxConvUTF8);
			wxLogMessage(msg_string);
			free(msg);
		}
	}
}  // end of DisplayErrorFile
开发者ID:ashengmz,项目名称:espeak,代码行数:25,代码来源:espeakedit.cpp

示例14: getFile

 FLAC__bool FLACInputStream::eof_callback(
   const FLAC__SeekableStreamDecoder* decoder,
   void* client_data)
 {
   File* file = getFile(client_data);
   return (file->tell() == GetFileLength(file));
 }
开发者ID:AlternatingCt,项目名称:ethanon,代码行数:7,代码来源:input_flac.cpp

示例15: GetFileLength

// --------------
// File position
// --------------
TFilePos::TFilePos(const KString& SFileName)
{
	m_FileName		= SFileName;
	m_szOffset		= 0;
	m_szLength		= GetFileLength(m_FileName);
	m_bPlainFile	= true;
}
开发者ID:tetratec,项目名称:runescape-classic-dump,代码行数:10,代码来源:file.cpp


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