Is there a c function in Gcc to set current drive (not just directory/folder). chdir() changes folder but I need to set the "active" drive (as in C:, D: etc.) Some compilers have _dos_setdrive() and chdrive() and Windows has its own but I could not find equivalent for gcc. My platform is do command prompt but Im also looking for Linux port (dunno if Linux has "drives"?)
Asked
Active
Viewed 337 times
1
-
Isn't the drive a part of the path? – Eugene Sh. May 26 '16 at 18:58
-
By *gcc*, do you meän MinGW? Or Cygwin? Anyway, just use the Win32 function for this, since "drives" are a Windows thing anyway. – hyde May 26 '16 at 19:00
1 Answers
1
Linux does not have drives. It has partitions. However, these are presented as one unified filesystem. Partitions are simply mounted at different directories. Therefore, there is no changing drives, just directories.
As for Windows, you need to use the Win32 API with MinGW (Assuming that is what you meant, otherwise if you are using Cygwin you would just chdir the same as linux, to /cygdrive/driveletter). Please see this question: How to use the Windows API in MinGW?