could in-progress files be Read-Only?

Technical discussion about the NMDC and <a href="http://dcpp.net/ADC.html">ADC</A> protocol. The NMDC protocol is documented in the <a href="http://dcpp.net/wiki/">Wiki</a>, so feel free to refer to it.

Moderator: Moderators

Locked
Da8add1e
Posts: 30
Joined: 2003-02-04 13:17
Location: Saddams Bunker :)

could in-progress files be Read-Only?

Post by Da8add1e » 2003-03-20 19:47

I have recently found that if i try to open archives etc. in programs that try to fix bad headers automatically or fix bad archives that if i accidentaly try to open an in-progress file it becomes corrupted

I had a look for some possible solutions and found that while File-Locking is possible e.g.

LockFileEx is defined as

Code: Select all

BOOL LockFileEx(
  HANDLE hFile,
  DWORD dwFlags,
  DWORD dwReserved,
  DWORD nNumberOfBytesToLockLow,
  DWORD nNumberOfBytesToLockHigh,
  LPOVERLAPPED lpOverlapped
);
and will lock the file to the calling application, i'm not sure if this is NTFS only but it is NT only, so unless DC++ is NT only perhaps this is not the best way :?:

another simpler way is for DC++ set the file attribute to read-only (except when writing from the buffer- Natchurly) as it's a simple matter to set-unset RO attribute before and after updating a file, although this isn't as "safe" as file-locking it would be good enough for DC++ purposes IMO and most likely stop me from corrupting more downloads :)

just a thought :idea:
Need NOT Greed (don't abuse poor countries)
Pay the Poor (increase minimum wage)
Tax the Rich (100% SuperTax rate)
(Do ya think thats maybe a little left-wing?)

Locked