https://github.com/freeslave/openfile
Opening std.stdio.File using a set of symbolic constants as a file access mode
https://github.com/freeslave/openfile
d dlang file
Last synced: 4 months ago
JSON representation
Opening std.stdio.File using a set of symbolic constants as a file access mode
- Host: GitHub
- URL: https://github.com/freeslave/openfile
- Owner: FreeSlave
- License: bsl-1.0
- Created: 2020-09-07T02:30:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-09T23:12:02.000Z (almost 5 years ago)
- Last Synced: 2025-01-22T14:45:53.710Z (over 1 year ago)
- Topics: d, dlang, file
- Language: D
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE_1_0.txt
Awesome Lists containing this project
README
# OpenFile
[](https://github.com/FreeSlave/openfile/actions/workflows/ci.yml)
[](https://ci.appveyor.com/project/FreeSlave/openfile)
[](https://coveralls.io/github/FreeSlave/openfile?branch=master)
**OpenFile** library provides functions for opening *std.stdio.File* using a set of symbolic constants instead of C-style string as a file access mode.
This approach allows setting a file access mode which is not possible or non-portable to express via string literals.
E.g. an exclusive mode which atomically ensures that the file does not exist upon creating.
Also someone might just prefer symbolic constants over string literals.
```
import openfile;
// Open a file in write mod and ensure that this is a new file with such name
// avoiding an accidental change of data written by some other process and ensuring that no other file with such name exists at the time of opening.
File f = openFile("test.txt", OpenMode.createNew);
```