It is currently Thu May 23, 2013 7:14 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to find reason for failed RenameFile()?
PostPosted: Mon Jun 25, 2012 10:29 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
Hi,

I want to move files using RenameFile() from network share with virus scanner to local share. If the virus scanner catches the file, I want to know it (to give user information). But RenameFile() is only saying Yes or No.

But there are many possible reasons for failure. I need to know if it has been because of:
- ERROR_FILE_NOT_FOUND
- ERROR_ACCESS_DENIED
- ERROR_INVALID_DRIVE
- ERROR_NOT_READY
- ERROR_READ_FAULT
- ERROR_VIRUS_INFECTED
- ERROR_VIRUS_DELETED

Any idea how to get this return codes without the need to use API (cross plattform)? Something like GetLastIOError() function?

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: How to find reason for failed RenameFile()?
PostPosted: Tue Jun 26, 2012 10:30 pm 
Offline
New User
New User

Joined: Tue May 08, 2012 11:06 pm
Posts: 8
You can use the API function "GetLastError" with PB functions as they call the API (on windows), but i would use "MoveFile" if using API error checking .... just in case!!

Code:
;result = RenameFile("||.ext", "nofile2.ext")
result = MoveFile_("||.ext", "nofile2.ext")

Buffer.s = Space(4096)
Chars.l = FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, Buffer, Len(Buffer), 0)
Debug Left(Buffer, Chars-2)


that would take care of the windows part, cant help for other OS's, soz


Top
 Profile  
 
 Post subject: Re: How to find reason for failed RenameFile()?
PostPosted: Wed Jun 27, 2012 1:22 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
Thanks MicroByte. Yes, that might work on Windows. MoveFile API is possibly the best solution.

But what is the return value of PB good for? Wouldn't it be much better to return some generalized errors? Maybe the most common ones in a PB specific way?

Anyway, I'd be happy to find the equivalents of Move_ on Linux and Mac...

Best

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye