FileSize() on a folder on network share not working?

Windows specific forum
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

FileSize() on a folder on network share not working?

Post by Kukulkan »

Hi,

we got two errors reported from customers where, after investigation, the PureBasic FileSize() function definitely returned -1 for an existing folder path like "//192.168.11.168/folder/". But in all our test environments it successfully returns -2 (it is a folder). From our point of view, the FileSize() function is now not reliable. Any ideas on this topic? Is FileSize() broken? Or maybe some Windows share folder issue? Or is this a know issue? Is there some reliable workaround?

Best,

Volker
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: FileSize() on a folder on network share not working?

Post by RSBasic »

I can't confirm it. It works here. I have no idea what it could be.
Maybe "Request User mode for Windows Vista and above (no virtualistion)" is not enabled?
Image
Image
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: FileSize() on a folder on network share not working?

Post by Kukulkan »

Hi RSBasic,

we can also not reproduce here, either. But we have logs from our software saying clearly that this folder was reported as -1 (file not found) instead of -2 (it is a folder). As it is considered "not existing", we then try to create the folder which obviously fails because it is already there.

"Request User mode for Windows Vista and above (no virtualistion)" is not enabled (we compile from the SHELL, so /USER is not used). But I dont think that such should have this sort of issues. All further file system operations (eg Directory listing and file/folder creation) are working fine on this path. Only FileSize() fails. Even folders below seem okay. Just the initial (root) folder fails.

"//192.168.11.168/folder/" -> -1
"//192.168.11.168/folder/subfolder" -> -2
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: FileSize() on a folder on network share not working?

Post by Kukulkan »

Issue is found:

it does not work if the target is the share directly (so said the "root" of the share). This is a bug because the root of a share is also a folder (due to MS):

Code: Select all

; Test this on Windows PB 5.46 LTS
FileName.s = "//192.168.11.4/Public/"
Debug "FileSize: " + Str(FileSize(FileName.s))
Debug "GetFileAttributes: " + Str(GetFileAttributes_(FileName) & #FILE_ATTRIBUTE_DIRECTORY)
 
FileName.s = "//192.168.11.4/Public/Misc/"
Debug "FileSize: " + Str(FileSize(FileName.s))
Debug "GetFileAttributes: " + Str(GetFileAttributes_(FileName) & #FILE_ATTRIBUTE_DIRECTORY) 
Result:
FileSize: -1
GetFileAttributes: 16
FileSize: -2
GetFileAttributes: 16

I will report this as a bug. It also happens on Linux, too.
Post Reply