You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
whentrue:
import std/os
let name =" foo.tmp"writeFile(name, "baz") # works
echo isValidFilename(name) # false
Current Output
false
Expected Output
true, since writeFile works
Example 2
the example should be converted to runnableExamples
Example 3
isValidFilename("") crashes
Possible Solution
add an optional param to isValidFilename to specify whether the filename is actually valid or (subjective) follows recommended guidelines (eg no space)
or fix isValidFilename implementation
or at very least clarify semantics in doc comments
i was exploring whether to use this to address #17914 (comment) but turns out it's useless for this purpose (and also doesn't check presence of DirSep etc)
The text was updated successfully, but these errors were encountered:
It says func only checks filenames very explicit, separators are not part of the "filename" by definition.
It is for when you need that a filename works on all OS without problems,
some filenames works on a given OS, and crash in another OS,
example you can create a file named CON on Linux, but it crashes your Windows.
Who wants filenames with trailing whitespaces anyway?.
Therefore "writeFile works" is not an absolute way to determine anything.
🤷
Maybe a new isValidPath() ?,
should it check whole paths, including separators, if the disk actually exists (C:/, Z:/, /something/, samba:/, etc),
if the disk is mounted, if the disk is an unix NFS is it network reachable, if the disk is an SSHFS do you have the keys,
may get more complicated, and not as cheap as the filename check, etc.
Example 1
Current Output
false
Expected Output
true, since writeFile works
Example 2
the example should be converted to runnableExamples
Example 3
isValidFilename("")
crashesPossible Solution
isValidFilename
to specify whether the filename is actually valid or (subjective) follows recommended guidelines (eg no space)isValidFilename
implementationAdditional Information
1.5.1 ee6d561
on osx
i was exploring whether to use this to address #17914 (comment) but turns out it's useless for this purpose (and also doesn't check presence of DirSep etc)
The text was updated successfully, but these errors were encountered: