fseek得到fileSize 和 fread得到filesize的区别
来源:互联网 发布:办假身份淘宝链接 编辑:程序博客网 时间:2024/05/31 06:23
/*!
***********************************************************************
* /brief
* allocates memory buf, opens file Filename in f, reads contents into
* buf and returns buf
* /param Filename
* name of config file
* /return
* if successfull, content of config file
* NULL in case of error. Error message will be set in errortext
***********************************************************************
*/
char *GetConfigFileContent (char *Filename)
{
long FileSize;
FILE *f;
char *buf;
if (NULL == (f = fopen (Filename, "r")))
{
snprintf (errortext, ET_SIZE, "Cannot open configuration file %s.", Filename);
return NULL;
}
if (0 != fseek (f, 0, SEEK_END))
{
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
return NULL;
}
FileSize = ftell (f);
if (FileSize < 0 || FileSize > 100000)
{
snprintf (errortext, ET_SIZE, "Unreasonable Filesize %ld reported by ftell for configuration file %s.", FileSize, Filename);
return NULL;
}
if (0 != fseek (f, 0, SEEK_SET))
{
snprintf (errortext, ET_SIZE, "Cannot fseek in configuration file %s.", Filename);
return NULL;
}
if ((buf = malloc (FileSize + 1))==NULL) no_mem_exit("GetConfigFileContent: buf");
// Note that ftell() gives us the file size as the file system sees it. The actual file size,
// as reported by fread() below will be often smaller due to CR/LF to CR conversion and/or
// control characters after the dos EOF marker in the file.
FileSize = (long) fread (buf, 1, FileSize, f);
buf[FileSize] = '/0';
fclose (f);
return buf;
}
- fseek得到fileSize 和 fread得到filesize的区别
- filesize的缓存问题
- fseek 和fread、fwrite的区别
- fseek 和fread、fwrite的区别
- 格式化FileSize
- php中的file_exists函数和filesize函数
- PHP fileperms()、filesize()和stat()函数
- fread()和fwrite() fseek()
- fseek、fread和fwrite
- fread、fwrite和fseek
- php filesize()错误
- iOS FileSize 转成string
- php filesize函数是个坑。。。
- PHP filesize 取得文件大小
- Shell命令编写——显示文件的大小filesize
- U-Boot中的filesize环境变量
- u-boot中filesize环境变量
- C文件流操作的fread和fseek
- 30X 状态码
- 【教程】NEC e-Border Client的设置图文教程(中文版)
- 查询数据库得DefaultTableModel
- linux静态链接库与动态链接库的区别及动态库的创建(转)
- 在ubuntu10.10中安装VMWare Tool,遇到The path " " is not valid 的问题
- fseek得到fileSize 和 fread得到filesize的区别
- 花五分钟弄的东西,和花半天弄出的东西,一眼就能看出来!即便你水平很牛了。
- Windows Server 2003 PSDK February 2003 Edition VC6 配置
- ORACLE中Drop table cascade constraints之后果
- Oracle Data Guard 主库报--RFS Possible network disconnect with primary database
- 哲哲发烧了
- BW:什么是权限变量:Authorization
- 几行py代码
- Sed