Commit graph

56 commits

Author SHA1 Message Date
Sönke Ludwig 69444da9a3 Work around missing AT_SYMLINK_NOFOLLOW declaration for Musl. 2021-01-18 14:30:33 +01:00
Sönke Ludwig 59912a7f21 Fix compilation of the directory iteration code on additional POSIX based platforms. 2021-01-18 14:30:33 +01:00
Sönke Ludwig 5e6231c738 Fix zero byte index computation. 2021-01-12 17:38:32 +01:00
Sönke Ludwig ca1fe41421 Add DirectoryListMode.shallowDirectories.
Shallow iteration, returning only directories. DirectoryListMode is now defined using bit combinations for "recursive" and "directories-only".
2021-01-12 17:37:02 +01:00
Sönke Ludwig d1273ca08b Fix the declaration of fstatat on macOS.
Was referencing the classic declaration that doesn't fit the current stat struct, leading to wrong stat results.
2021-01-12 17:37:02 +01:00
Sönke Ludwig 1f0ac47b9d Rework the listDirectory implementation.
- Directly uses OS facilities instead of Phobos to avoid string processing overhead and to enable fast skipping of non-directories
- Introduces a DirectoryListMode, similar to SpanMode
- Uses low-overhead channels to reduce the communication overhead between the calling thread and the worker thread that calls the OS
- Adds FileInfo.path to properly support the new recursive directory iteration schemes
2021-01-12 10:55:29 +01:00
Sönke Ludwig a9ba6d98cb Fix bogus file access denied error after listDirectory calls on Windows.
Makes sure that `FindClose` gets called before `listDirectory` returns to avoid a race-condition, where a successive modification of the directory fails with "access denied".
2020-12-01 19:23:05 +01:00
Sönke Ludwig eb183d5ab2 Use concurrent pipe() in copyFile(). 2020-10-21 17:37:36 +02:00
Sönke Ludwig f5c6099656 Work around critical issue in eventcore's cancelRead/cancelWrite.
The file I/O versions of cancelRead and cancelWrite in eventcore currently do not reliably cancel the operation in a synchronous fashion, leading to continued buffer accesses after the cancellation call. In case of the Windows version, this also means that the OVERLAPPED structure can be illegally reused for the next operation, while the previous one hasn't been canceled, yet.

A solution to this issue may require a fundamental change in the file I/O API of eventcore, and the optimal design of that still needs to be worked out. For this reason, we simply avoid using the cancellation functions in vibe-core for now to avoid memory corruption issues. This does mean that interrupting a task that does file I/O won't work anymore.
2020-09-18 10:09:16 +02:00
Geod24 9a685523f9 Add support for DMD 2.094 -preview=in switch
This will allow users to use -preview=in as soon as it's released.
2020-08-31 06:59:50 +02:00
Sönke Ludwig a4e87237e4 Remove potentially blocking file I/O code (upgrade to eventcore 0.9.0).
- file and pipe closing are now asynchronous operations
- moveFile and removeFile are now executed in a worker thread
- requires eventcore ~>0.9.0
2020-05-17 15:10:01 +02:00
Sönke Ludwig cef4885a63 Update change log. 2020-03-18 15:32:26 +01:00
Sönke Ludwig 8e24c4a204 Correct copyright holder.
rejectedsoftware e.K. doesn't exist anymore since mid-2019.
2020-01-27 19:20:52 +01:00
Sönke Ludwig f56fd7580c Avoid reallocating the data in readFileUTF8 if the UTF encoding is valid.
Uses the immutable overload of sanitizeUTF8 to reuse the original buffer if possible.
2019-10-22 11:41:35 +02:00
Sönke Ludwig d9e545bf60 Fix getFileInfo's exception handling and reduce overhead of the background work.
Instead of asyncWork, now uses a worker task directly and signals the finalization of the result using message passing. This avoids the roundtrip required to return the task handle, as well as the heap allocated result buffer of Future!T.
2019-08-25 12:02:08 +02:00
Sönke Ludwig ce1adf8c3b
Merge pull request #172 from vibe-d/async_file_operations
Avoid all blocking file operations outside of worker threads
2019-08-21 20:59:45 +02:00
Sönke Ludwig e3a38b374e Let all non-aio file system functions run in worker threads.
This avoids stalling the event loop in case of lengthy I/O (network shares, spinning up hard drives etc).
2019-08-21 13:34:00 +02:00
v1ne 513bebcb95 FileStream: Approximate the file offset better when appending
Instead of starting at zero, start at the current file size. This offset
is stored in FileStream. It is only an approximation because concurrent
writes could advance the file without FileStream's knowledge.

Add a test that shows that the offset is approximated as expected and that
appending to an existing file works, too.

This is also a regression test which shows that appending to an existing
file works as expected. See vibe-d/eventcore#115.
2019-07-26 00:38:15 +02:00
v1ne ce9faec1c1 FileStream: Forbid seek(.) or truncate(.) when appending to a file
Those functions do not work for files opened for appending. Make this clear.
2019-07-26 00:29:59 +02:00
v1ne 3ebb065509 Clean up: Use "enforce" 2019-07-26 00:29:59 +02:00
Sönke Ludwig 989577ff23 Fix copyFile setting file times of write protected files. 2019-06-16 15:10:50 +02:00
Sönke Ludwig a86f25b3b4 Fix range violation in makeFileInfo and add some unit tests. 2019-04-05 09:47:32 +02:00
Sönke Ludwig 8e4adf000f Make the DirEntry->FileInfo conversion nothrow.
Avoids listDirectory/iterateDirectory getting interrupted when stumbling over inaccessible files. The `name` field of the returned file info value is always set, so that these files can still be identified.
2019-03-25 09:45:47 +01:00
Francesco Mecca 6292320bb2 support isFile 2019-03-21 17:39:44 +01:00
Sönke Ludwig 2f552ac408 Properly handle directory watcher creation failures. 2019-01-14 14:59:03 +01:00
Sönke Ludwig 9583df3c44 Preserve times and attributes in copyFile. 2019-01-14 14:59:02 +01:00
Sönke Ludwig c899798be7 Avoid blocking copy in moveFile. 2019-01-14 00:34:15 +01:00
Benjamin Schaaf 12a8825f86
Fix error message in FileStream.write 2019-01-07 10:26:16 +11:00
The Dlang Bot e5d53249fc
Merge pull request #113 from vibe-d/file_truncate
Add FileStream.truncate
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
2018-12-28 14:03:19 +01:00
Sönke Ludwig f35e8f1d69 Add FileStream.truncate. 2018-12-28 10:14:50 +01:00
Hiroki Noda a408aac808 Use monotonic clock for timeout 2018-12-24 06:22:53 +09:00
Sönke Ludwig 2c63aa5c5c Allow destructors to run in foreign threads. Fixes #69.
This change modifies destructors to anticipate that they can be called form a foreign thread if the GC is involved. The actual release of the reference will then happen deferred in the original thread.
2018-03-16 18:06:53 +01:00
Sönke Ludwig dad84e8a46 Adjust DirectoryWatcher implementation for changed FileChange definition in eventcore. 2017-11-21 21:42:44 +01:00
Sönke Ludwig 094de42f97 Update change log. 2017-11-17 11:56:18 +01:00
Sönke Ludwig 2a106ebcbb Add FileInfo.hidden. 2017-11-07 16:14:02 +01:00
Sönke Ludwig 710c996666
Add assertion message. 2017-10-30 22:55:22 +01:00
Sönke Ludwig a6eeae97f3 Fix DirectoryWatcher's creation of its LocalManualEvent. 2017-07-20 16:52:34 +02:00
Sebastian Wilzbach 8f89733a86 Remove all trailing whitespace
sed 's/[ \t]*$//' -i **/*.d
2017-07-03 12:19:27 +02:00
Sönke Ludwig 07e077a009
Redesign the Path type to statically encode the path format.
The previous design, while intended as an improvement over the one-size-fits all Path struct of vibe-d:core, turned out to produce lots of bugs during the transition, because of missing Path.type checks.

The new design uses a cleaner approach, where the static type of a path value encodes the path format. An explicit cast is necessary to convert between different path types. The internet path type also performs proper validation and percent encoding, so that InetPath.toString() always produces a valid URI path.
2017-06-21 14:04:24 +02:00
Sönke Ludwig 6f7c897f91 Fix getFileInfo name return value for paths that end with a slash. 2017-06-12 17:31:52 +02:00
Sönke Ludwig 0aed5664ef
Let openFile throw on failure instead of returning an invalid stream. 2017-05-30 10:57:31 +02:00
Sönke Ludwig 1d9e88f27a Fix createTempFile on Windows. 2017-03-09 16:09:46 +01:00
Sönke Ludwig 68430a1ea4
Fix file pointer management in FileStream. Fixes rejectedsoftware/vibe.d#1684. 2017-02-16 23:37:41 +01:00
Sönke Ludwig e88d2d1b4b
Fix segfault in DirectoryWatcher. 2017-01-29 22:11:17 +01:00
Sönke Ludwig 5f980acefd
Upgrade to latest eventcore. 2017-01-25 21:04:13 +01:00
Sönke Ludwig 2acc60934f
Add IOMode parameters to stream read/write methods. 2017-01-19 00:36:32 +01:00
Sönke Ludwig fdfbb55aa8 Re-implement ManualEvent.
This simplifies the logic by separating thread local notifications from cross-thread notifications, as well as replacing lockless operations by a spin lock. The thread local variant of ManualEvent is now also separated into a LocalManualEvent type.
2017-01-13 22:24:18 +01:00
Sönke Ludwig 35a94412d0 Make FileStream small enough to fit into an InterfaceProxy. 2016-12-26 21:28:36 +01:00
Sönke Ludwig 79656a80df Fix safety error on Windows. 2016-12-19 16:16:50 +01:00
Sönke Ludwig a7bfbc1c45 Implement createTempFile on Posix. 2016-12-10 16:01:40 +01:00