• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 766
  • Last Modified:

C functions to query Linux file system

How do I get the size of a file on Linux from within a C++ program (compiled with gcc)?  The file to be queried will be only partially written.  Where can I find documentation on similar file system functions?
0
DeathByChocolate
Asked:
DeathByChocolate
1 Solution
 
masheikCommented:
Hi,
take this snippet and try it out,
 
int currentFileSize(FILE *inFile)
{
 int sizeinBytes;
 fseek(inFile,NULL,SEEK_CURRENT);
 sizeinBytes=ftell(inFile);
 return sizeinBytes;
}

Open in new window

0
 
DeathByChocolateAuthor Commented:
thanks for the answer..  I found the stat() function, which was really what I was looking for.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now