本文整理汇总了C++中GetFileLength函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileLength函数的具体用法?C++ GetFileLength怎么用?C++ GetFileLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFileLength函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: ReadPhFile
static int ReadPhFile(char **ptr, const char *fname)
{//=================================================
FILE *f_in;
char *p;
unsigned int length;
char buf[200];
sprintf(buf,"%s%c%s",path_home,PATHSEP,fname);
length = GetFileLength(buf);
if((f_in = fopen(buf,"rb")) == NULL)
{
fprintf(stderr,"Can't read data file: '%s'\n",buf);
return(1);
}
if(*ptr != NULL)
Free(*ptr);
if((p = Alloc(length)) == NULL)
{
fclose(f_in);
return(-1);
}
if(fread(p,1,length,f_in) != length)
{
fclose(f_in);
return(-1);
}
*ptr = p;
fclose(f_in);
return(0);
} // end of ReadPhFile
开发者ID:JKcompute,项目名称:395_midi_controller,代码行数:33,代码来源:mcu_synthdata.c
示例17: GetFileLength
int TXTFAM::Cardinality(PGLOBAL g)
{
if (g) {
int card = -1;
int len = GetFileLength(g);
if (len >= 0) {
if (Padded && Blksize) {
if (!(len % Blksize))
card = (len / Blksize) * Nrec;
else
sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, Lrecl);
} else {
if (!(len % Lrecl))
card = len / (int)Lrecl; // Fixed length file
else
sprintf(g->Message, MSG(NOT_FIXED_LEN), To_File, len, Lrecl);
} // endif Padded
if (trace)
htrc(" Computed max_K=%d Filen=%d lrecl=%d\n",
card, len, Lrecl);
} else
card = 0;
// Set number of blocks for later use
Block = (card > 0) ? (card + Nrec - 1) / Nrec : 0;
return card;
} else
return 1;
} // end of Cardinality
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:35,代码来源:filamtxt.cpp
示例18: sprintf
static char *ReadPhFile(void *ptr, const char *fname, int *size)
{//=============================================================
FILE *f_in;
char *p;
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)
{
fprintf(stderr,"Can't read data file: '%s'\n",buf);
return(NULL);
}
if(ptr != NULL)
Free(ptr);
if((p = Alloc(length)) == NULL)
{
fclose(f_in);
return(NULL);
}
if(fread(p,1,length,f_in) != length)
{
fclose(f_in);
return(NULL);
}
fclose(f_in);
if(size != NULL)
*size = length;
return(p);
} // end of ReadPhFile
开发者ID:PaulBoersma,项目名称:praat,代码行数:35,代码来源:synthdata.cpp
示例19: FinalizeDay
//+------------------------------------------------------------------+
//| Cut the file |
//+------------------------------------------------------------------+
void CLogger::Cut(void)
{
FILE *in,*out;
char *buf,*cp,tmp[256];
int len;
//---- закроем файл на всякий случай
m_sync.Lock();
FinalizeDay();
//---- откроем файл заново, проверим размер
_snprintf(tmp,sizeof(tmp)-1,"%s.log",ExtProgramPath);
if((in=fopen(tmp,"rb"))==NULL) { m_sync.Unlock(); return; }
len=GetFileLength(in);
if(len<300000) { fclose(in); m_sync.Unlock(); return; }
//---- allocate 100 Kb for last messages and read them
if((buf=(char*)malloc(102401))==NULL) { fclose(in); m_sync.Unlock(); return; }
fseek(in,len-102400,SEEK_SET);
fread(buf,102400,1,in); buf[102400]=0;
fclose(in);
//---- reopen log-file and write last messages
if((out=fopen(tmp,"wb"))!=NULL)
{
if((cp=strstr(buf,"\n"))!=NULL) fwrite(cp+1,strlen(cp+1),1,out);
fclose(out);
}
free(buf);
//----
m_sync.Unlock();
}
开发者ID:dailypips,项目名称:TradeSharp,代码行数:31,代码来源:Logger.cpp
示例20: file
bool MD5Animation::LoadAnimation( const std::string& filename )
{
if ( !fs::exists(filename) )
{
std::cerr << "MD5Animation::LoadAnimation: Failed to find file: " << filename << std::endl;
return false;
}
fs::path filePath = filename;
std::string param;
std::string junk; // Read junk from the file
fs::ifstream file(filename);
int fileLength = GetFileLength( file );
assert( fileLength > 0 );
m_JointInfos.clear();
m_Bounds.clear();
m_BaseFrames.clear();
m_Frames.clear();
m_AnimatedSkeleton.m_Joints.clear();
m_iNumFrames = 0;
file >> param;
while( !file.eof() )
{
if ( param == "MD5Version" )
{
file >> m_iMD5Version;
assert( m_iMD5Version == 10 );
}
else if ( param == "commandline" )
开发者ID:rinrynque,项目名称:md5,代码行数:34,代码来源:MD5Animation.cpp
注:本文中的GetFileLength函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论