FileAndDirs: Dealing with Files and Directories
FileAndDirs is part of the CategoryAplTree project.
With version 15.0 Dyalog has introduced several new system functions that make it much easier to write platform independent code when it comes to dealing with files and directories.
However, there are some gaps left: copying and moving files for example, or a recursive directory listing.
FilesAndDirs aims to close this gap: it offers the same functionality for Windows, Linux and Mac OS.
Slashes and backslashes
Under Windows the backslash \ character is used as delimiter. Under Linux and Mac OS it is the / character. However, Windows is willing to accept the / rather than the \ in most cases, and in all when we do something by a program. The easiest way therefore seems to be to use / everywhere.
Almost. As it turns out there are several occasions when one still has to settle for the \:
- Calls to third party software.
- Calls to .NET assemblies.
Setting properties like Directory in the FileBox GUI objects.
For that reason since version 1.3 all methods of FilesAndDirs accept both the / and the \ characters as directory seperators but when returning a result that is a path name then it will always make sure that the correct separator for the given operating system is used.
That's the reason why the class offers method like Exists, CreateFile, DeleteFile and even NNAMES and NCREATE: they don't do much more than their system function equivalents except that they normalize any filenames and directory names.
Of course this means that FilesAndDirs cannot deal under Linux and Mac OS with names that contain a \, but if you try to write platform independent code then you must not do this anyway, and most likely you shouldn't even if you don't.
Cd CheckPath CopyTo CopyTree CreateFile CurrentSep DeleteFile Dir EnforceBackslash EnforceSlash Exists GetNewLineCharsFor GetTempFilename GetTempPath IsDir IsFile IsSymbolicLink ListDirs ListFiles MkDir MoveTo MoveTree NCREATE NNAMES NormalizePath PolishCurrentDir PWD RmDir Version
Find out more by looking into the documentation FilesAndDirsDocumentation.html
For bug reports, future enhancements and a full version history see FilesAndDirs/ProjectPage
FilesAndDirs needs version 15.0 Unicode of Dyalog APL, or better.
Using an APLTree member
- If you just want to consume (use) an APLTree member then you have several choices:
Download it from its dedicated download page http://download.aplwiki.com/
Access it via FTP: ftp://ftp.aplwiki.com/APLTree/ with the user ID "anonymous". There is no password needed.
- Note that accessing it via ftp allows you to download older versions as well while the dedicated download page offers just the most current version.
If you want to contribute to an APLTree project see HowToContributeToTheAPLTreeProject for details.
Get the full project
If for some reason you need access to, say, the test cases then you need to get more then just the script (or application) itself.
HowToContributeToTheAPLTreeProject explains how to get a project onto your local machine. Just ignore any additional steps.