ADDED: GetFileSize()
This commit is contained in:
parent
524bf57b74
commit
0f00c41aad
2 changed files with 18 additions and 0 deletions
|
@ -1041,6 +1041,7 @@ RLAPI bool SaveFileText(const char *fileName, char *text); // Save text d
|
|||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (including point: .png, .wav)
|
||||
RLAPI int GetFileSize(const char *fileName); // Get file size in bytes
|
||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
||||
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)
|
||||
|
|
17
src/rcore.c
17
src/rcore.c
|
@ -2851,6 +2851,23 @@ bool DirectoryExists(const char *dirPath)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Get file size in bytes
|
||||
int GetFileSize(const char *fileName)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
FILE *file = fopen(fileName, "rb");
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
fseek(file, 0L, SEEK_END);
|
||||
size = (int)ftell(file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// Get pointer to extension for a filename string (includes the dot: .png)
|
||||
const char *GetFileExtension(const char *fileName)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue