| | |
Coressponding Linux function/library out of Win32...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hello there, anyone here knows what is the function or library in Linux that corresponds to the win32 functions/library given bellow.
library
- #include <Windows.h>
functions
- GetDiskFreeSpaceEx()、GetFileAttribute()、GetModuleFileName()、GetFileVersionInfoSize()、GetFileVersion( )
Thank you!
library
- #include <Windows.h>
functions
- GetDiskFreeSpaceEx()、GetFileAttribute()、GetModuleFileName()、GetFileVersionInfoSize()、GetFileVersion( )
Thank you!
Retreat!!!
See man fstat
fstat gives you struct stat for a given file. This struct has following info abt your file:
It's a system call.
fstat gives you struct stat for a given file. This struct has following info abt your file:
c Syntax (Toggle Plain Text)
mode_t st_mode; /* File mode (see mknod(2)) */ ino_t st_ino; /* Inode number */ dev_t st_dev; /* ID of device containing */ /* a directory entry for this file */ dev_t st_rdev; /* ID of device */ /* This entry is defined only for */ /* char special or block special files */ nlink_t st_nlink; /* Number of links */ uid_t st_uid; /* User ID of the file's owner */ gid_t st_gid; /* Group ID of the file's group */ off_t st_size; /* File size in bytes */ time_t st_atime; /* Time of last access */ time_t st_mtime; /* Time of last data modification */ time_t st_ctime; /* Time of last file status change */ /* Times measured in seconds since */ /* 00:00:00 UTC, Jan. 1, 1970 */ long st_blksize; /* Preferred I/O block size */ blkcnt_t st_blocks; /* Number of 512 byte blocks allocated*/ char st_fstype[_ST_FSTYPSZ]; /* Null-terminated type of filesystem */
Are you Agile.. ?
I tried to used the function to my hard drive but it's giving me a -1 return. I checked the mode it's both readable and writable for the root and ordinary users. T_T. *sigh*. What do you think is the problem? Here's my code.
c++ Syntax (Toggle Plain Text)
//#include <sys/vfs.h> #include <sys/types.h> #include <fcntl.h> #include <sys/stat.h> #include <iostream> using namespace std; struct stat buffer; int status; off_t size; blkcnt_t fblock; int main(){ size = buffer.st_size; fblock = buffer.st_blocks; int fildes = open("/dev/hda", O_RDWR); status = fstat(fildes, &buffer); cout << "size: " << size << endl; cout << "free blocks: " << fblock << endl; cout << status << endl; return 0; }
Retreat!!!
>> int fildes = open("/dev/hda", O_RDWR);
Seems like you're trying to access a special file (device)
I donno abt those. Check is the man page says anything abt it.
There are at least 2 attributes that indicate this:
1. dev_t st_rdev; /* ID of device */
2. char st_fstype[_ST_FSTYPSZ]; /* Null-terminated type of filesystem */
But they only seem to indicate that it's a special file.
Seems like you're trying to access a special file (device)
I donno abt those. Check is the man page says anything abt it.
There are at least 2 attributes that indicate this:
1. dev_t st_rdev; /* ID of device */
2. char st_fstype[_ST_FSTYPSZ]; /* Null-terminated type of filesystem */
But they only seem to indicate that it's a special file.
Are you Agile.. ?
> GetDiskFreeSpaceEx()
Dunno, but the 'df' command line program provides this information. If you could locate the Linux source for that program, perhaps you'll find out how it's done.
> GetFileAttribute()
Use the stat() API as described already. Should be good for regular files and directories.
Remember, if it returns -1, then look at the 'errno' variable to find out why it failed.
> GetModuleFileName()
The nearest equivalent is argv[0], as passed to your main()
> GetFileVersionInfoSize()
> GetFileVersion( )
AFAIK, there is no consistent way of putting version information into a file. Shared libraries in particular encode the version into the filename, but that's about it.
Dunno, but the 'df' command line program provides this information. If you could locate the Linux source for that program, perhaps you'll find out how it's done.
> GetFileAttribute()
Use the stat() API as described already. Should be good for regular files and directories.
Remember, if it returns -1, then look at the 'errno' variable to find out why it failed.
> GetModuleFileName()
The nearest equivalent is argv[0], as passed to your main()
> GetFileVersionInfoSize()
> GetFileVersion( )
AFAIK, there is no consistent way of putting version information into a file. Shared libraries in particular encode the version into the filename, but that's about it.
@thekashyap - Oh, I see. I'm actually dealing with the cd/dvd-rw drive and the media inside it. As what I have read, the function GetDiskFreeSpaceEx( ) has a parameter that deals with the free space in the cd/dvd media, but I'm not quite sure of that. I saw a function which is,I think, quite similar to fstat(), it's statvfs and fstatvfs. I tried both but they still give the same 0 value on the size and the free blocks. *sigh*.
@Salem - I'll try these one dude.
@thekashyap and Salem - Thanks!
@Salem - I'll try these one dude.
@thekashyap and Salem - Thanks!
Last edited by jaepi; Jun 18th, 2007 at 10:23 pm.
Retreat!!!
![]() |
Similar Threads
- Cubed root function? (C++)
- Function call problem (HTML and CSS)
Other Threads in the C++ Forum
- Previous Thread: C++ filesystem operations??
- Next Thread: Please help with assignment
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






