Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-03-2005, 01:13 PM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
File Read Error Messages

I am currently in need of at least 5-6 reasons why a file might not be read properly. Here is what i have so far:

The file has been moved, renamed or deleted.
It contains corrupt/invalid data.

These are to be displayed in a message when an error occurrs whilst reading or opening a file. See Below:

Quote:
FILE READ ERROR...
An error occurred whilst attempting to access Students.txt
This might be because:
>> The file has been moved, renamed or deleted.
>> It contains corrupt/invalid data
>> The file is empty
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 09-03-2005, 02:14 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Something like this ?
Code:
if(access(file_name, F_OK))
    /* file does not exist */
if(access(file_name, R_OK))
    /* No read permission */
if(!(file_pointer=fopen(file_name, "r")))
    /* Unable to open file */
if(feof(file_pointer))
   /* file is empty */
while(!feof(file_pointer))
{
    if(!fread(buffer, sizeof(buffer), 1, file_pointer))
        /* premature end of file */
    if(!valid(buffer))
        /* illformed or unexpected data */
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 09-03-2005, 02:58 PM   #3 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
I know how to do it through coding, only can you think of 5-6 reasons why an error may occur. These are to be displayed to the user, along with a message explaining 5-6 solutions on why an error may have occured.

Can you think of any more? Two are listed above.

Many Thanks
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 09-04-2005, 08:36 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
So you need only four more:
- No rights to access/modify/etc.. file.
- File locked.
- Network or media unaccessable.
- File doesn't exist.
__________________
Valmont is offline   Reply With Quote
Old 09-04-2005, 09:28 AM   #5 (permalink)
Locutus
Registered User
 
Join Date: Aug 2005
Posts: 20
Locutus is on a distinguished road
Read or open? Anyway, the man page / API documentation for a particular function generally has information about error codes and potential causes.
Locutus is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting java to read from a file. philthee Java 6 10-27-2004 09:00 AM


All times are GMT -8. The time now is 04:17 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting