|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
File not found vs. Can not read file
when opening a file, I need to distinguish between file not found and a file that cannot be read to output proper error messages.
for file not found I am using if (file.fail()) But how can I detect whether a file cannot be read? For example this being it has no read permissions thanks. |
|
#2
|
|||
|
|||
|
hi!
which os does your program run on? which specific programming language do you use? and what is file.fail()? trying to answer your question: 1. search for "stat()" 2. you could check if your programming language has a function called "int file_exists(char *filename)" or similar. 3. you could read the permissions and ownership first from the file and then check the current uid/gid against that. err. the first would fail already for "file not found"... ![]() 4. afaik there should be a function getLastError() or similar where you can read the last error-code. and another function that outputs the osīs default error string for this error. can you supply more specific infos please?
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > File not found vs. Can not read file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|