Differences between revisions 48 and 57 (spanning 9 versions)
Revision 48 as of 2012-11-05 03:30:44
Size: 1919
Editor: KaiJaeger
Comment: Update
Revision 57 as of 2017-02-27 20:56:32
Size: 2768
Editor: anonymous
Comment: accept/except
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Dealing with Files and Directories =
{{{WinFile}}} is part of the CategoryAplTree project.
= FileAndDirs: Dealing with Files and Directories =

{{{FileAndDirs}}} is part of the CategoryAplTree project.
Line 7: Line 8:
Nowadays if there is a need to deal with directories and files, there is .NET, right? Well, some companies have decided against .NET, so there is still the need for a .NET-free solution to this. This is what the WinFile class is designed for.
Line 9: Line 9:
But there is more to say to this: try to get a DirectoryInfo for a directory with, say, 100,000 files. Then compare with this class. 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.
Line 11: Line 11:
See the list of methods (generated with [[ADOC]]): 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.
Line 14: Line 32:
Line 17: Line 36:
  CopyToWithRC
Line 19: Line 37:
  DateOf
  Delete
  DirTree
  DirX
  CopyTree
  CreateFile
  CurrentSep
  DeleteFile
Line 24: Line 42:
  DoesExistDir
  DoesExistFile
  DoesExist
  ExpandEnv
  ExpandPath
  GetAllDrives
  GetDriveAndType
  GetTempFileName
  EnforceBackslash
  EnforceSlash
  Exists
  GetNewLineCharsFor
  GetTempFilename
Line 33: Line 48:
  History
IsDirEmpty
  IsFilenameOkay
  IsFoldernameOkay
  IsVal
idWin32Filename
  ListDirsOnly
  ListDirXIndice
s
  ListFileAttributes
  IsDir
  IsFile
  IsSymbolicLink
  ListDirs
  ListFiles
Line 42: Line 54:
  MoveToWithRC
Line 44: Line 55:
  MoveTree
  NCREATE
  NNAMES
  NormalizePath
Line 46: Line 61:
  ReadAnsiFile
Line 49: Line 63:
  WriteAnsiFile
  YoungerThan
Line 53: Line 65:
== Fields ==
{{{
  COL_CreationDateName
  COL_LastAccessDate
  COL_LastWriteDate
  COL_Name
  COL_ShortName
  COL_Size
  FA_ARCHIVE
  FA_COMPRESSED
  FA_DEVICE
  FA_DIRECTORY
  FA_ENCRYPTED
  FA_HIDDEN
  FA_NORMAL
  FA_NOT_CONTENT_INDEXED
  FA_OFFLINE
  FA_READONLY
  FA_REPARSE_POINT
  FA_SPARSE_FILE
  FA_SYSTEM
  FA_TEMPORARY
  FA_VIRTUAL
  okay
}}}
Find out more by looking into the documentation [[attachment:WinFileDocumentation.html]]
Find out more by looking into the documentation [[attachment:FilesAndDirsDocumentation.html]]
Line 82: Line 69:
For bug reports, future enhancements and a full version history see WinFile/ProjectPage For bug reports, future enhancements and a full version history see FilesAndDirs/ProjectPage
Line 89: Line 76:
`WinFile` needs version 13.0 of Dyalog APL. `FilesAndDirs` needs version 15.0 Unicode of Dyalog APL, or better.

FileAndDirs: Dealing with Files and Directories

FileAndDirs is part of the CategoryAplTree project.

Overview

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.

Methods

  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

Project Page

For bug reports, future enhancements and a full version history see FilesAndDirs/ProjectPage

Version Information

Original author:

KaiJaeger

Responsible:

KaiJaeger

Email:

kai@aplteam.com

FilesAndDirs needs version 15.0 Unicode of Dyalog APL, or better.


CategoryAplTree

FilesAndDirs (last edited 2018-03-03 11:44:34 by KaiJaeger)