Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
49c13f4f
Commit
49c13f4f
authored
Mar 11, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new procedures to read files.
parent
795b5a6c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletions
+52
-1
src/misc/extra/extra.h
+2
-0
src/misc/extra/extraUtilFile.c
+50
-1
No files found.
src/misc/extra/extra.h
View file @
49c13f4f
...
@@ -104,8 +104,10 @@ extern char * Extra_FileNameExtension( char * FileName );
...
@@ -104,8 +104,10 @@ extern char * Extra_FileNameExtension( char * FileName );
extern
char
*
Extra_FileNameAppend
(
char
*
pBase
,
char
*
pSuffix
);
extern
char
*
Extra_FileNameAppend
(
char
*
pBase
,
char
*
pSuffix
);
extern
char
*
Extra_FileNameGeneric
(
char
*
FileName
);
extern
char
*
Extra_FileNameGeneric
(
char
*
FileName
);
extern
char
*
Extra_FileNameGenericAppend
(
char
*
pBase
,
char
*
pSuffix
);
extern
char
*
Extra_FileNameGenericAppend
(
char
*
pBase
,
char
*
pSuffix
);
extern
int
Extra_FileCheck
(
char
*
pFileName
);
extern
int
Extra_FileSize
(
char
*
pFileName
);
extern
int
Extra_FileSize
(
char
*
pFileName
);
extern
char
*
Extra_FileRead
(
FILE
*
pFile
);
extern
char
*
Extra_FileRead
(
FILE
*
pFile
);
extern
char
*
Extra_FileReadContents
(
char
*
pFileName
);
extern
int
Extra_FileIsType
(
char
*
pFileName
,
char
*
pS1
,
char
*
pS2
,
char
*
pS3
);
extern
int
Extra_FileIsType
(
char
*
pFileName
,
char
*
pS1
,
char
*
pS2
,
char
*
pS3
);
extern
char
*
Extra_TimeStamp
();
extern
char
*
Extra_TimeStamp
();
extern
char
*
Extra_StringAppend
(
char
*
pStrGiven
,
char
*
pStrAdd
);
extern
char
*
Extra_StringAppend
(
char
*
pStrGiven
,
char
*
pStrAdd
);
...
...
src/misc/extra/extraUtilFile.c
View file @
49c13f4f
...
@@ -203,11 +203,38 @@ char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix )
...
@@ -203,11 +203,38 @@ char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
Extra_FileCheck
(
char
*
pFileName
)
{
FILE
*
pFile
;
pFile
=
fopen
(
pFileName
,
"rb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Extra_FileCheck(): File
\"
%s
\"
does not exist.
\n
"
,
pFileName
);
return
0
;
}
fseek
(
pFile
,
0
,
SEEK_END
);
if
(
ftell
(
pFile
)
==
0
)
printf
(
"Extra_FileCheck(): File
\"
%s
\"
is empty.
\n
"
,
pFileName
);
fclose
(
pFile
);
return
1
;
}
/**Function*************************************************************
Synopsis [Returns the file size.]
Description [The file should be closed.]
SideEffects []
SeeAlso []
***********************************************************************/
int
Extra_FileSize
(
char
*
pFileName
)
int
Extra_FileSize
(
char
*
pFileName
)
{
{
FILE
*
pFile
;
FILE
*
pFile
;
int
nFileSize
;
int
nFileSize
;
pFile
=
fopen
(
pFileName
,
"r"
);
pFile
=
fopen
(
pFileName
,
"r
b
"
);
if
(
pFile
==
NULL
)
if
(
pFile
==
NULL
)
{
{
printf
(
"Extra_FileSize(): The file is unavailable (absent or open).
\n
"
);
printf
(
"Extra_FileSize(): The file is unavailable (absent or open).
\n
"
);
...
@@ -252,6 +279,28 @@ char * Extra_FileRead( FILE * pFile )
...
@@ -252,6 +279,28 @@ char * Extra_FileRead( FILE * pFile )
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Read the file into the internal buffer.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char
*
Extra_FileReadContents
(
char
*
pFileName
)
{
FILE
*
pFile
;
char
*
pBuffer
;
pFile
=
fopen
(
pFileName
,
"rb"
);
pBuffer
=
pFile
?
Extra_FileRead
(
pFile
)
:
NULL
;
if
(
pFile
)
fclose
(
pFile
);
return
pBuffer
;
}
/**Function*************************************************************
Synopsis [Returns one if the file has a given extension.]
Synopsis [Returns one if the file has a given extension.]
Description []
Description []
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment