digitalmars.D.learn - Copying file to /dev/null
- axricard (18/20) Jan 24 ``` D
- Jonathan M Davis (6/26) Jan 24 Per copy's documentation, it preserve's the file's timestamps, and looki...
``` D import std; void main() { auto sourceName = deleteme ~ "source"; auto source = File(sourceName, "w"); source.write("source"); copy(sourceName, "/dev/null"); } ``` The copy to /dev/null fails : `std.file.FileException std/file.d(4348): /dev/null: Invalid argument`, which is a little surprising. Why would it be an invalid argument ? The cp command for example doesn't raise any error : ```0 ```cp source /dev/null echo $?
Jan 24
On Friday, January 24, 2025 2:57:05 AM MST axricard via Digitalmars-d-learn wrote:``` D import std; void main() { auto sourceName = deleteme ~ "source"; auto source = File(sourceName, "w"); source.write("source"); copy(sourceName, "/dev/null"); } ``` The copy to /dev/null fails : `std.file.FileException std/file.d(4348): /dev/null: Invalid argument`, which is a little surprising. Why would it be an invalid argument ? The cp command for example doesn't raise any error : ```Per copy's documentation, it preserve's the file's timestamps, and looking at where the exception is coming from, setting the access and modification times on /dev/null is apparently illegal (which isn't particularly surprising). - Jonathan M Davis0 ```cp source /dev/null echo $?
Jan 24