I just want to know the search range of fopen()
in :
a) Windows
b) Unix-like systems like MacOS & Linux
When asked to open a file for reading, or reading & writing or even just writing, with a relative path, e.g. File.txt
. And I need an answer addressing both - text & binary files.
Does it scan only the current directory, or does it scan particular folders ?
(Since scanning full disk would be painstakingly slow, right ?)
fopen() doesn't scan at all It just opens the file you tell it to open. The path is either absolute, or relative to the current directory. The behaviour is pretty much the same across platforms.
Of course in Windows paths look a bit different (drive letters, backslashes instead of slashes).
One relevant difference I can think of: If the path starts with a drive letter and a colon, it will look at another drive. If there is no backslash after the drive letter and colon, then the location will be relative to that drive's current working directory (as Windows remembers a current directory per drive letter).