Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / How to get the Filesize

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. How to get the Filesize
#2647
Posted by: HeReSY 2003-09-19 16:54:20
Hi,

anybody an answer of this question.
I only found functions to create, close, open, read and write files, but i didn't find a function which returns the size of a file.

HeReSY
Message2. Re: How to get the Filesize
#2648
Posted by: guidance 2003-09-19 20:06:39
Try wxStat(), it's a wrapper of stat().
Message3. Re: How to get the Filesize
#2714
Posted by: 2003-10-08 18:23:46
I had the same problem. I solved it with open the file, and the Returncode of SeekEnd tells the position.

stat / wxStat seems to be better, but could not find ANYTHING in the documentation. is it an undocumentet wxFile function? Any more information could be helpful!
Thank's
Markus
Message4. Re: How to get the Filesize
#2716
Posted by: guidance 2003-10-08 19:29:12
stat is a standard function in libc, document:
http://g.yi.org/f.php?f=2853#2968

wxWindows wrapped many standard functions to better interface with wxWindows, for instance, with wxString, unicode, etc. You can search header files in include directory for their definitions.
Message5. Re: How to get the Filesize
#2724
Posted by: HeReSY 2003-10-10 09:50:49
I have made it with wxFileInputStream. The Base class has the member function GetSize() and it works goog.

HeReSY
Message6. Re: How to get the Filesize
#2725
Posted by: 2003-10-10 14:57:31
simple but good AND the file does not need to be opened like in the other solutions:

wxStructStat buf;
int result,size;
wxString cur_file;
....
    result = wxStat( cur_file, &buf );
    if (result != 0 ) size = -1; // file is unknown => has no size
    else              size = buf.st_size;

Message7. Re: How to get the Filesize
#2727
Posted by: HeReSY 2003-10-10 18:35:37
Which header do i have to include. I included the filefn.h where wxStat is declared, but the compiler says, that he did'nt no such function.

HeReSY
Message8. Re: How to get the Filesize
#2729
Posted by: 2003-10-10 19:04:26
I see, the filefn does not include everything, it needs.
#include <sys/stat.h>
... should help, in my systems it compiles with GCC and Visual C++
Markus
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0