Joutsen v0.5.0+12-g5dd5f7e
Public Member Functions | Properties | List of all members
Joutsen.IO.LocalFolder Class Reference

A class representing a folder in the file system. More...

Public Member Functions

 LocalFolder (string path)
 Creates a new Folder instance for a path represented by a string. More...
 
 LocalFolder (LocalFilesystemPath path)
 Creates a new Folder instance for a path. More...
 
void Create ()
 Creates the folder. More...
 
Folder CopyTo (String dstPath, bool recursive, bool overwrite=false, bool copyOnlyContents=false)
 Copies the folder to a different path. More...
 
Folder CopyTo (FilesystemPath dstPath, bool recursive, bool overwrite=false, bool copyOnlyContents=false)
 Copies the folder to a different path. More...
 
Folder MoveTo (string dstPath, bool keepFolder=false)
 Moves the folder to a different location. More...
 
Folder MoveTo (LocalFilesystemPath dstPath, bool keepFolder=false)
 Moves the folder to a different location. More...
 
Folder MoveTo (FilesystemPath dstPath, bool keepFolder=false)
 Moves the folder to a different location. More...
 
void Delete (bool recursive=false)
 Deletes the folder from the filesystem. More...
 
Set< LocalFilesystemPathList (string searchPattern="*")
 Lists the content of the folder. More...
 
Set< LocalFolderListFolders (string searchPattern="*")
 Lists the folders contained in this folder. More...
 
Set< LocalFileListFiles (string searchPattern="*")
 Lists the files contained in this folder. More...
 
SCG.IEnumerable< LocalFilesystemPathWalk (string searchPattern="*")
 Walks the filesystem returning one file or folder contained in this folder at a time. More...
 
SCG.IEnumerable< LocalFolderWalkFolders (string searchPattern="*")
 Walks the filesystem returning one subfolder of this folder at a time. More...
 
SCG.IEnumerable< LocalFileWalkFiles (string searchPattern="*")
 Walks the filesystem returning one file contained in this folder at a time. More...
 
override bool Equals (object obj)
 Compares this instance to another one for equality. More...
 
override int GetHashCode ()
 Calculates the hash code for this instance. More...
 
override string ToString ()
 Creates a string representation of this folder instance. More...
 
void Create ()
 Creates the folder. More...
 
Folder CopyTo (String dstPath, bool recursive, bool overwrite=false, bool copyOnlyContents=false)
 Copies the folder to a different path. More...
 
Folder CopyTo (FilesystemPath dstPath, bool recursive, bool overwrite=false, bool copyOnlyContents=false)
 Copies the folder to a different path. More...
 
Folder MoveTo (string dstPath, bool keepFolder=false)
 Moves the folder to a different location. More...
 
Folder MoveTo (FilesystemPath dstPath, bool keepFolder=false)
 Moves the folder to a different location. More...
 
void Delete (bool recursive=false)
 Deletes the folder from the filesystem. More...
 
Set< FilesystemPathList (string searchPattern="*")
 Lists the content of the folder. More...
 
Set< FolderListFolders (string searchPattern="*")
 Lists the folders contained in this folder. More...
 
Set< FileListFiles (string searchPattern="*")
 Lists the files contained in this folder. More...
 
SCG.IEnumerable< FilesystemPathWalk (string searchPattern="*")
 Walks the filesystem returning one file or folder contained in this folder at a time. More...
 
SCG.IEnumerable< FolderWalkFolders (string searchPattern="*")
 Walks the filesystem returning one subfolder of this folder at a time. More...
 
SCG.IEnumerable< FileWalkFiles (string searchPattern="*")
 Walks the filesystem returning one file contained in this folder at a time. More...
 

Properties

String Name [get]
 The name of the folder. More...
 
LocalFolder Parent [get]
 The path of the parent folder. More...
 
LocalFilesystemPath Path [get]
 The path of the folder. More...
 
DateTime LastModificationTime [get]
 The time the folder was last changed. More...
 
DateTime CreationTime [get]
 The time the folder was created. More...
 
bool Exists [get]
 Checks if the folder exists in the filesystem. More...
 
bool IsWritable [get]
 Checks if the folder can be written to in the filesystem. More...
 
- Properties inherited from Joutsen.IO.Folder
String Name [get]
 The name of the folder. More...
 
Folder Parent [get]
 The path of the parent folder. More...
 
FilesystemPath Path [get]
 The path of the file. More...
 
DateTime LastModificationTime [get]
 The time the folder was last changed. More...
 
DateTime CreationTime [get]
 The time the folder was created. More...
 
bool Exists [get]
 Checks if the folder exists in the filesystem. More...
 
bool IsWritable [get]
 Checks if the folder is writable in the filesystem. More...
 

Detailed Description

A class representing a folder in the file system.

Remarks
The folder does not have to exist. It can also be a potential folder.
Since
0.4.0

Constructor & Destructor Documentation

◆ LocalFolder() [1/2]

Joutsen.IO.LocalFolder.LocalFolder ( string  path)

Creates a new Folder instance for a path represented by a string.

Parameters
paththe path to the folder. Can be absolute or relative.
Exceptions
System.ArgumentNullExceptionif path is null
System.ArgumentExceptionif path is empty or leads to a file

◆ LocalFolder() [2/2]

Joutsen.IO.LocalFolder.LocalFolder ( LocalFilesystemPath  path)

Creates a new Folder instance for a path.

Parameters
paththe path to the folder. Can be absolute or relative.
Exceptions
System.ArgumentNullExceptionif path is null
System.ArgumentExceptionif path is empty or leads to a file

Member Function Documentation

◆ CopyTo() [1/2]

Folder Joutsen.IO.LocalFolder.CopyTo ( FilesystemPath  dstPath,
bool  recursive,
bool  overwrite = false,
bool  copyOnlyContents = false 
)

Copies the folder to a different path.

Parameters
dstPaththe path to copy the folder to
recursivedetermines if subfolders should be copied as well
overwritedetermines if an existing folder at dstPath should be replaced
Returns
the folder representing the copy
Exceptions
System.ArgumentNullExceptionif dstPath is null
Remarks
Copying a folder is not an atomic operation. Therefore it is likely that parts of the folder are already copied if an error occurs during the copy process. These parts are not cleaned up.

Implements Joutsen.IO.Folder.

◆ CopyTo() [2/2]

Folder Joutsen.IO.LocalFolder.CopyTo ( String  dstPath,
bool  recursive,
bool  overwrite = false,
bool  copyOnlyContents = false 
)

Copies the folder to a different path.

Parameters
dstPaththe path to copy the folder to
recursivedetermines if subfolders should be copied as well
overwritedetermines if an existing folder at dstPath should be replaced
Returns
the folder representing the copy
Remarks
Copying a folder is not an atomic operation. Therefore it is likely that parts of the folder are already copied if an error occurs during the copy process. These parts are not cleaned up.

Implements Joutsen.IO.Folder.

◆ Create()

void Joutsen.IO.LocalFolder.Create ( )

Creates the folder.

Implements Joutsen.IO.Folder.

◆ Delete()

void Joutsen.IO.LocalFolder.Delete ( bool  recursive = false)

Deletes the folder from the filesystem.

Parameters
recursivedetermines if the folder should only be deleted if it is empty or if files and subfolders should be deleted as well

Implements Joutsen.IO.Folder.

◆ Equals()

override bool Joutsen.IO.LocalFolder.Equals ( object  obj)

Compares this instance to another one for equality.

Parameters
objthe instance to check for equality

◆ GetHashCode()

override int Joutsen.IO.LocalFolder.GetHashCode ( )

Calculates the hash code for this instance.

◆ List()

Set< LocalFilesystemPath > Joutsen.IO.LocalFolder.List ( string  searchPattern = "*")

Lists the content of the folder.

Parameters
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in this folder sorted by their names

Implements Joutsen.IO.Folder.

◆ ListFiles()

Set< LocalFile > Joutsen.IO.LocalFolder.ListFiles ( string  searchPattern = "*")

Lists the files contained in this folder.

Parameters
searchPatterncan be used to restrict the result to files matching this pattern
Returns
the files in this folder sorted by their names

Implements Joutsen.IO.Folder.

◆ ListFolders()

Set< LocalFolder > Joutsen.IO.LocalFolder.ListFolders ( string  searchPattern = "*")

Lists the folders contained in this folder.

Parameters
searchPatterncan be used to restrict the result to folders matching this pattern
Returns
the folders in this folder sorted by their names

Implements Joutsen.IO.Folder.

◆ MoveTo() [1/3]

Folder Joutsen.IO.LocalFolder.MoveTo ( FilesystemPath  dstPath,
bool  keepFolder = false 
)

Moves the folder to a different location.

Parameters
dstPaththe path to move the folder to
keepFolderif keepFolder is false the content of the folder will be moved to the new location. If it is false the folder is moved into the folder defined by dstPath
Returns
the Folder representing the moved folder
Remarks
In order to support moving files to any location on any filesystem, this is not an atomic operation but rather a copy and delete combination. This can result in effects like changed creation times etc.
Exceptions
System.ArgumentNullExceptionif dstPath is null

Implements Joutsen.IO.Folder.

◆ MoveTo() [2/3]

Folder Joutsen.IO.LocalFolder.MoveTo ( LocalFilesystemPath  dstPath,
bool  keepFolder = false 
)

Moves the folder to a different location.

Parameters
dstPaththe path to move the folder to
keepFolderif keepFolder is false the content of the folder will be moved to the new location. If it is false the folder is moved into the folder defined by dstPath
Returns
the Folder representing the moved folder

◆ MoveTo() [3/3]

Folder Joutsen.IO.LocalFolder.MoveTo ( string  dstPath,
bool  keepFolder = false 
)

Moves the folder to a different location.

Parameters
dstPaththe path to move the folder to
keepFolderif keepFolder is false the content of the folder will be moved to the new location. If it is false the folder is moved into the folder defined by dstPath
Returns
the Folder representing the moved folder

Implements Joutsen.IO.Folder.

◆ ToString()

override string Joutsen.IO.LocalFolder.ToString ( )

Creates a string representation of this folder instance.

◆ Walk()

SCG.IEnumerable< LocalFilesystemPath > Joutsen.IO.LocalFolder.Walk ( string  searchPattern = "*")

Walks the filesystem returning one file or folder contained in this folder at a time.

Parameters
searchPatterncan be used to restrict the result to files and folders matching this pattern
Returns
the files and folders in this folder one at a time

Implements Joutsen.IO.Folder.

◆ WalkFiles()

SCG.IEnumerable< LocalFile > Joutsen.IO.LocalFolder.WalkFiles ( string  searchPattern = "*")

Walks the filesystem returning one file contained in this folder at a time.

Parameters
searchPatterncan be used to restrict the result to files matching this pattern
Returns
the files in this folder one at a time

Implements Joutsen.IO.Folder.

◆ WalkFolders()

SCG.IEnumerable< LocalFolder > Joutsen.IO.LocalFolder.WalkFolders ( string  searchPattern = "*")

Walks the filesystem returning one subfolder of this folder at a time.

Parameters
searchPatterncan be used to restrict the result to folders matching this pattern
Returns
the folders in this folder one at a time

Implements Joutsen.IO.Folder.

Property Documentation

◆ CreationTime

DateTime Joutsen.IO.LocalFolder.CreationTime
get

The time the folder was created.

Implements Joutsen.IO.Folder.

◆ Exists

bool Joutsen.IO.LocalFolder.Exists
get

Checks if the folder exists in the filesystem.

Implements Joutsen.IO.Folder.

◆ IsWritable

bool Joutsen.IO.LocalFolder.IsWritable
get

Checks if the folder can be written to in the filesystem.

Remarks
This is an expensive operation because the only save way to determine if the folder is writable is by temporarily creating a file. Additionally access rights can be changed between this check and the actual writing, still resulting in an exception. Therefore it is recommended to use this method as sparsly as possible and instead simply try to write to the folder and handling a possible exception because it is cheaper and more secure.

Implements Joutsen.IO.Folder.

◆ LastModificationTime

DateTime Joutsen.IO.LocalFolder.LastModificationTime
get

The time the folder was last changed.

Implements Joutsen.IO.Folder.

◆ Name

String Joutsen.IO.LocalFolder.Name
get

The name of the folder.

Implements Joutsen.IO.Folder.

◆ Parent

LocalFolder Joutsen.IO.LocalFolder.Parent
get

The path of the parent folder.

Implements Joutsen.IO.Folder.

◆ Path

LocalFilesystemPath Joutsen.IO.LocalFolder.Path
get

The path of the folder.

Implements Joutsen.IO.Folder.