July 12, 2016 How to open file with exclusive lock? | ||||
---|---|---|---|---|
| ||||
I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desirable that no other thread be able to access the file in read mode. (Ditto for other processes.) stdio.file.lock (or is it stdio.file.File.lock?) seems to demand a range of chunks to lock, but the file is not fixed in length. Is it appropriate to just specify the maximum possible number of bytes (i.e. ulong.max)? |
July 12, 2016 Re: How to open file with exclusive lock? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Hixson | On Tuesday, 12 July 2016 at 18:54:18 UTC, Charles Hixson wrote: > I want to open a file with an exclusive lock. It would be important that no other thread be able to access the file in write mode, and desirable that no other thread be able to access the file in read mode. (Ditto for other processes.) > > stdio.file.lock (or is it stdio.file.File.lock?) seems to demand a range of chunks to lock, but the file is not fixed in length. Is it appropriate to just specify the maximum possible number of bytes (i.e. ulong.max)? From the lock[1] description: > If both start and length are zero, the entire file is locked. [1] https://dlang.org/phobos/std_stdio.html#.File.lock |
Copyright © 1999-2021 by the D Language Foundation