[TC11.50B2] TC moved file to not yet spinned up external USB drive
Moderators: Hacker, petermad, Stefan2, white
- ghisler(Author)
- Site Admin
- Posts: 50824
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive
OK, I will try calling FindFirstFile before trying to copy or move files. It it takes longer than a second, I will wait another second and call it again. Since my USB disks don't have this problem, I would appreciate if you could test this change after the release of beta 7.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 50824
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive
Unfortunately calling FindFirstFile did not wake up my USB drive. The only way to make it wake up was to actually cause a write operation, e.g. by changing the attributes of the parent directory. Setting it to the same value it already had did NOT cause a spin up! Therefore I will not use this method for now.
Instead I'm checking whether it helps to listen to WM_DEVICECHANGE messages, which are sent for example when external drives are being disconnected (which you described above). But I don't know whether the message is sent quickly enough to prevent TC from deleting the file after copying it to the disconnected drive. Could you try it with some test file, please? You should get an English warning that the drive was removed. It may only work with larger files, though.
Instead I'm checking whether it helps to listen to WM_DEVICECHANGE messages, which are sent for example when external drives are being disconnected (which you described above). But I don't know whether the message is sent quickly enough to prevent TC from deleting the file after copying it to the disconnected drive. Could you try it with some test file, please? You should get an English warning that the drive was removed. It may only work with larger files, though.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive
Why not just call WriteFile with 0 bytes and with the flag at first writing file?ghisler(Author) wrote: 2024-11-20, 17:51 UTC Unfortunately calling FindFirstFile did not wake up my USB drive. The only way to make it wake up was to actually cause a write operation, e.g. by changing the attributes of the parent directory. Setting it to the same value it already had did NOT cause a spin up! Therefore I will not use this method for now.
Instead I'm checking whether it helps to listen to WM_DEVICECHANGE messages, which are sent for example when external drives are being disconnected (which you described above). But I don't know whether the message is sent quickly enough to prevent TC from deleting the file after copying it to the disconnected drive. Could you try it with some test file, please? You should get an English warning that the drive was removed. It may only work with larger files, though.
Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive
Hopefully not as TC default just to fix a problem only reported once.andry81 wrote: 2024-11-21, 11:40 UTC ...
Why not just call WriteFile with 0 bytes and with the flag at first writing file?
Windows 11 Home, Version 24H2 (OS Build 26100.4351)
TC 11.55 RC6 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.3 x64
TC 11.55 RC6 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.3 x64
- ghisler(Author)
- Site Admin
- Posts: 50824
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: [TC11.50B2] TC moved file to not yet spinned up external USB drive
Because the default copy method does not use CreateFile/ReadFile/WriteFile but uses CopyFileEx. Normally CopyFileEx fails when it can't spin up the drive, so TC doesn't delete the original file. But andry81's strange drive disconnects during spin up, and CopyFileEx still reports success. I hope that I can detect the disconnect before trying to delete the file.Why not just call WriteFile with 0 bytes and with the flag at first writing file?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com