Page 1 of 1

CRC32FileFingerprint failure

Posted: Sat Jun 04, 2011 3:39 pm
by doctorized
I have downloaded some avi files to a folder. I use CRC32FileFingerprint to get the CRC code for every file. In some cases the crc returned is 0 and PB says: "[warning] The specified file does not exist." If these files are moved to another folder then crc code is returned fine. Why? The initial folder is named "M:\Completed\CSI Miami - Season 03 - HDTV". What is wrong?

Re: CRC32FileFingerprint failure

Posted: Sat Jun 04, 2011 9:08 pm
by tinman
doctorized wrote:I have downloaded some avi files to a folder. I use CRC32FileFingerprint to get the CRC code for every file. In some cases the crc returned is 0 and PB says: "[warning] The specified file does not exist." If these files are moved to another folder then crc code is returned fine. Why? The initial folder is named "M:\Completed\CSI Miami - Season 03 - HDTV". What is wrong?
I'm guessing here but it sounds like it could be a clash in the sharing of files between processes.

From your description it looks as if you are using a torrent to download the AVI, which I guess you will be seeding after it has downloaded. Is that correct?

If PB is trying to open the file with a sharing mode incompatible to that of the torrent application then it will not be able to open the file and you will get the "file does not exist" error. Have you tried closing the torrent application and then running the CRC32FileFingerprint?

I wouldn't assume that it's PB's fault if that turns out to be the case. It could be that the torrent application opens the file exclusively, i.e. not shared so PB (nor anything else) would ever be able to open it while the torrent application has it open. It might also only show up as a problem on files that you have finished downloading since you last started the torrent application, as it might be smart enough to open files that have completed in a shared read mode.

Re: CRC32FileFingerprint failure

Posted: Sat Jun 04, 2011 11:29 pm
by happer66
He shouldn't be able to move the files to another folder if another process has them locked though..?

You could try this code by Little John to test if they are indeed ''locked''

Code: Select all

;Original code by Little John
;http://forums.purebasic.com/english/viewtopic.php?f=5&t=44978
EnableExplicit
Define Result, TestFile$, TestPath$ = "M:\Completed\CSI Miami - Season 03 - HDTV\";GetTemporaryDirectory()
Procedure.i FileIsClosed (fileName$)
   ; returns #False if the file does not exist, or if it is opened by another process;
   ;         #True otherwise
   ;
   ; Note: By passing zero as 3rd parameter for CreateFile_(),
   ;       we request *exclusive* access to the respective file.
   ;       This fails if the file is already open.
   ; <http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx>
   ; <http://msdn.microsoft.com/en-us/library/aa363874%28v=vs.85%29.aspx>
   Protected handle
   
   handle = CreateFile_(@fileName$, #GENERIC_READ, 0, #Null, #OPEN_EXISTING, #FILE_ATTRIBUTE_NORMAL, #Null)
   If handle = #INVALID_HANDLE_VALUE
      ProcedureReturn #False
   Else
      CloseHandle_(handle)
      ProcedureReturn #True
   EndIf   
EndProcedure

If ExamineDirectory(0, TestPath$, "*.*")  
  While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_File
      TestFile$ = TestPath$ + DirectoryEntryName(0)
      Result = FileIsClosed(TestFile$)
      If Result = #False
        Debug "Another process has exclusive access to this file: " + TestFile$
      EndIf
    EndIf
  Wend
  FinishDirectory(0)
Else
  Debug "oops, that directory doesn't exist...."
EndIf

Re: CRC32FileFingerprint failure

Posted: Sun Jun 05, 2011 12:05 am
by tinman
happer66 wrote:He shouldn't be able to move the files to another folder if another process has them locked though..?
True, I forgot about that.

If it's not a locking problem then it is probably something else at the filesystem level, as it still works for the file in a different path. There's no reason for CRC32FileFingerprint to fail to open a file that exists, unless that error message is incorrect.

Other things to check:
security permissions of the directory that the download is going into against the user who is executing the PB code
anti-virus/malware logs to see if access has been blocked

There was also something I remember for .CHM files, that Windows Explorer kept a flag to say that it had been downloaded from the internet and it would either block access or ask you to allow access when you tried to open it. Maybe there is something similar for AVI files?

Re: CRC32FileFingerprint failure

Posted: Sun Jun 05, 2011 11:17 am
by doctorized
@ happer66: tried your code and it says "Another process has exclusive access to this file" for all the files in the directory, as I am seeding with uTorrent 3.0.
Thank you my firends for your replays!

Re: CRC32FileFingerprint failure

Posted: Sun Jul 15, 2012 12:51 pm
by SeregaZ
in my case CRC32FileFingerprint shows less than 0. Debug CRC32FileFingerprint("C:\Program Files\NAT\GDMS3\DSMonitor.exe") shows "-125226421" it is ok? i mean return minus it is normal?

in old 4.30PB, in droopy CRC32 shows "FFFFFFFFF889324B" it is more than 0...

Re: CRC32FileFingerprint failure

Posted: Sun Jul 15, 2012 1:45 pm
by netmaestro
The results are identical, CRC32FileFingerprint is returning a long.