Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DELFILESQQ error codes

andrew_4619
Honored Contributor III
1,154 Views

I was just fixing a bug in some codes and used the IFPORT routine i2=DELFILESQQ(gfile(1:ilen)) where gfile="C:\fullpath\filname.xls", the path is not long ilen is about 60 characters long. The file is not open. If the file is readonly in windows then i2=0 (no file deleted) and I call getlasterrorqq(). which returns a value of 22. The using the help and ifport the return values are    !ERR$ZERO=0 ERR$NOMEM=12, ERR$ACCES=13, ERR$INVAL=22, ERR$NOENT=2.

I was expecting ERR$ACCES but get ERR$INVAL is this correct? The reason I ask is is specifically wanted to know if it was an access rights error. I am running W7 SP1 X64.

As a check if I run the same routine with the read only box unchecked on the file I get i2=1 as one would expect.

0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,154 Views

DELFILESQQ doesn't set an error status, so GETLASTERRORQQ is returning something not relevant to the DELFILESQQ operation. Note that the documentation for DELFILESQQ doesn't mention using GETLASTERRORQQ. You could try calling the Windows API routine GetLastError to see if you get something useful from that.

0 Kudos
andrew_4619
Honored Contributor III
1,154 Views

Thats not what the help file for GETLASTERRQQ says... It lists DELFILEQQ as one of its routines and lists ERR$NOMEM, ERR$ACCES, ERR$NOENT, ERR$INVAL as the error messages.

0 Kudos
Steven_L_Intel1
Employee
1,154 Views

Ok - I looked a bit closer. DELFILESQQ uses the C unlink function, and GETLASTERRORQQ just returns the C "errno" value, so yes, those are valid choices. Why unlink is returning INVAL, I don't know. You may want to try the WIndows API DeleteFile function and see what it does.

0 Kudos
andrew_4619
Honored Contributor III
1,154 Views

win api gives ERROR_ACCESS_DENIED  (0x5) Access is denied. This is what is expected. I thus suspect DELFILEQQ is misinterpretting the C error codes.

0 Kudos
Steven_L_Intel1
Employee
1,154 Views

DELFILESQQ doesn't even look at the C error code - it just calls unlink and increments the count if it succeeds. GETLASTERROQQ simply returns errno. It could be that unlink is doing something special here.

0 Kudos
andrew_4619
Honored Contributor III
1,154 Views

this is not a problem DELFILESQQ is now ditched from my  utilities function in favour of the win api. Looking at unlink error codes (which was basically written for unix like systems) some error codes do not translate to windows that well!

0 Kudos
Reply