| | |
understanding file system
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 116
Reputation:
Solved Threads: 0
So I started doing c programing and now I want to understand how file systems like fat 32 and NTFS works. So I want to know how to create a file transfering program. So here's a few questions....
1 How do I do it the portable way?
-find file size
-what data type to use in C to do the transfer
-explain the following:
2 How to do it through windows
-how to call windows copy and cut functions, so that you get a popup dialog box that shows the trasfer in progress
-does it return anything to indicate a success or failure?
3 How to get file names from a given directory so that it is in the form of a 2d array
- how and where are those file names stored?
1 How do I do it the portable way?
-find file size
-what data type to use in C to do the transfer
-explain the following:
•
•
•
•
from what I understand txt files are treated differently from other files [I think this only applies for windows systems]
-how to call windows copy and cut functions, so that you get a popup dialog box that shows the trasfer in progress
-does it return anything to indicate a success or failure?
3 How to get file names from a given directory so that it is in the form of a 2d array
- how and where are those file names stored?
Since you mentioned C, so I cannot suggest you Boost::Filesystem
You will have to use platform specific codes like
I guess you can use any(not sure)
Again this is very compiler/OS specific. You can see some examples here
You will have to use platform specific codes like
stat of unix and some equivalent function in windows with chain of #ifdef's. You can also use fstat, or fseek to the end of the file and then use ftell. But both of will give you exact result only in case of binary files because of differing representation of end-of-line. I guess you can use any(not sure)
•
•
•
•
3 How to get file names from a given directory so that it is in the form of a 2d array
Getting the list of files from a directory is not too difficult but is os-dependent. In C there is no portable way to do it. In C++ boost libraries have portable functions.
these code snippets show how to do it in both linux and ms-windows.
these code snippets show how to do it in both linux and ms-windows.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Oct 2006
Posts: 116
Reputation:
Solved Threads: 0
Well I'm not looking for a single function to do all this really. I mean alot of HDs are formated in NTFS or FAT32, so if I'm correct HDs have something called FAT which says where everything is located. So how is that data expressed. Is it a list of pointers followed by its file name? Can C even get to it?
Isn't C portable to the point you can creat an OS with it???
Isn't C portable to the point you can creat an OS with it???
•
•
•
•
Well I'm not looking for a single function to do all this really. I mean alot of HDs are formated in NTFS or FAT32, so if I'm correct HDs have something called FAT which says where everything is located. So how is that data expressed. Is it a list of pointers followed by its file name? Can C even get to it?
Each sector the contains a file has a pointer which can point to the next sector if the file occupies more than one. In this way, a file is basically a linked list of sectors.
Yes, it's possible to create an operating system with C. However, because of the low level-ness needed in the program, a lot of assembly is required, forcing it to be hardware-specific.
"Technological progress is like an axe in the hands of a pathological criminal."
I think you have your concepts blurred there. Portability roughly impiles the same standard C code can be compiled on Windows system as well as Unix system. (of course provided you don't use external libraries).
Yes, C can be used to create an OS with it (and it has already been achieved), but for interfacing external devices like the hard drive or floppy drive, you need to write a program (ie a driver) which will act as an interpreter between the OS and the device.
Yes, C can be used to create an OS with it (and it has already been achieved), but for interfacing external devices like the hard drive or floppy drive, you need to write a program (ie a driver) which will act as an interpreter between the OS and the device.
I don't accept change; I don't deserve to live.
•
•
•
•
Well I'm not looking for a single function to do all this really. I mean alot of HDs are formated in NTFS or FAT32, so if I'm correct HDs have something called FAT which says where everything is located. So how is that data expressed. Is it a list of pointers followed by its file name? Can C even get to it?
Yes. But you have to keep in mind each OS is written specifically for the hardware it runs on. So even though C is portable does not mean you can write an OS that's portable.
•
•
•
•
So I started doing c programing and now I want to understand how file systems like fat 32 and NTFS works. So I want to know how to create a file transfering program. So here's a few questions....
1 How do I do it the portable way?
-find file size
char
•
•
•
•
-explain the following:
2 How to do it through windows
-how to call windows copy and cut functions, so that you get a popup dialog box that shows the trasfer in progress
-does it return anything to indicate a success or failure?
•
•
•
•
3 How to get file names from a given directory so that it is in the form of a 2d array
- how and where are those file names stored?
C itself knows nothing about hard drives, monitors, or keyboards. The I/O functions defined by C are just skeleton definitions to be defined via the standards by the compiler designers to work within the confines of the O/S.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- File System simulation (Java)
- File System Error 1026???? (Windows 95 / 98 / Me)
- extending windows "file system" attributes (C#)
- Cannot detect the drive names and their file system (Windows NT / 2000 / XP)
- a device file in system.ini file damaged (Windows 95 / 98 / Me)
- Errors with Linux file system (*nix Hardware Configuration)
- Error occured during the file system check. (*nix Software)
- Checking file on System C (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: explode text into array
- Next Thread: Which is nicer?
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project 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 visualstudio win32 windows winsock wordfrequency wxwidgets






