digitalmars.D.bugs - [Issue 9455] New: File.isBinaryMode and more
- d-bugmail puremagic.com (29/29) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9455
- d-bugmail puremagic.com (27/30) Jul 09 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9455
http://d.puremagic.com/issues/show_bug.cgi?id=9455 Summary: File.isBinaryMode and more Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc Some functions I write take a File reference and write some binary data on it. So in their pre-condition I'd like to assert the File to be not just open, but also opened in binary mode. I think currently there is no handy way to know if a std.stdio.File is opened in binary or text mode (or in write or read mode). After a short discussion on IRC #D with jA_cOp, I think a way to implement this feature is: - Add isBinaryMode/isWriteable/isReadable properties to File, and implement them as light wrappers around platform-specific functions that get that information. - in most cases a std.stdio.File is created with a file name and a mode string, while the usage of std.stdio.File.wrapFile() is uncommon. So on systems where those platform-specific functions are not available a workaround is to keep this mode string given to the File.__ctor. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9455 Kevin L <kevin.lamonte gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kevin.lamonte gmail.com ---- Add isBinaryMode/isWriteable/isReadable properties to File, and implement them as light wrappers around platform-specific functions that get that information.I vote that there be five new functions: * isReadable(inout(C)[] path) (or perhaps canRead()): for files, a std.stdio.open(..., "r") will succeed; for directories, std.file.dirEntries() will succeed. * isWriteable(inout(C)[] path) (or perhaps canWrite()): for files, a std.stdio.open(..., "w") will succeed; for directories, creating a new file in the directory will succeed (excluding things like no space on device). Open question if this function should detect write-only media and return false if so. * isExecutable(inout(C)[] path) (or perhaps canExecute()): for files, exec()/fork()/popen()/etc. (and wrappers) will succeed; always false for directories. * isTraversable(inout(C)[] path): always false for files; for directories, a chdir() will succeed OR a file in the directory can be stat()d. (This is the traditional POSIX view of execute bit on a directory.) * std.stdio.File.isBinary(): returns true if the file was opened with "rb" or "wb". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 09 2013