Skip to content

Commit

Permalink
Implemented get size functionality from file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Kalatozishvili committed Jun 29, 2024
1 parent c737bc7 commit e3d45ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/sys/xfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,22 @@ int XPath_GetPerm(char *pOutput, size_t nSize, const char *pPath)
return XPath_ModeToPerm(pOutput, nSize, statbuf.st_mode);
}

long XPath_GetSize(const char *pPath)
{
xfile_t srcFile;

if (XFile_Open(&srcFile, pPath, NULL, NULL) >= 0)
{
XFile_GetStats(&srcFile);
long nSize = srcFile.nSize;

XFile_Close(&srcFile);
return nSize;
}

return XSTDERR;
}

int XPath_CopyFile(const char *pSrc, const char *pDst)
{
xfile_t srcFile;
Expand Down
1 change: 1 addition & 0 deletions src/sys/xfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ int XPath_PermToMode(const char *pPerm, xmode_t *pMode);
int XPath_ModeToPerm(char *pOutput, size_t nSize, xmode_t nMode);
int XPath_ModeToChmod(char *pOutput, size_t nSize, xmode_t nMode);

long XPath_GetSize(const char *pPath);
uint8_t* XPath_Load(const char *pPath, size_t* pSize);
int XPath_CopyFile(const char *pSrc, const char *pDst);
int XPath_Read(const char *pPath, uint8_t *pBuffer, size_t nSize);
Expand Down
2 changes: 1 addition & 1 deletion src/xver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define XUTILS_VERSION_MAX 2
#define XUTILS_VERSION_MIN 5
#define XUTILS_BUILD_NUMBER 51
#define XUTILS_BUILD_NUMBER 52

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit e3d45ce

Please sign in to comment.