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

A class representing a temporarily available folder in the filesystem. More...

Public Member Functions

 TemporaryFolder (bool createFolder=true, bool removeCreatedFolders=false)
 Creates a new folder located in the temporary folder of the local foldersystem. More...
 
 TemporaryFolder (String path, bool createFolder=true, bool removeCreatedFolders=false)
 Creates a new folder in the location and with the name specified by. More...
 
 TemporaryFolder (FilesystemPath path, bool createFolder=true, bool removeCreatedFolders=false)
 Creates a new folder in the location and with the name specified by. More...
 
 TemporaryFolder (Folder folder, bool createFolder=true, bool removeCreatedFolders=false)
 Creates a new folder in the location and with the name specified by. More...
 
void Create ()
 Creates the folder without content. 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...
 
void Dispose ()
 Removes the temporary folder if possible. 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...
 

Protected Member Functions

 TemporaryFolder (Folder folder, bool removeCreatedFolders)
 
TemporaryFolder CreateTemporaryFolder (Folder newFolder)
 
virtual void Dispose (bool disposing)
 

Protected Attributes

Folder folder
 
List< TemporaryFoldercreatedFolders
 

Properties

String Name [get]
 The name of the folder. More...
 
FilesystemPath Path [get]
 The path of the folder. More...
 
Folder Parent [get]
 The folder where the folder is located. 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 foldersystem. More...
 
bool IsWritable [get]
 Checks if the folder is writable in the foldersystem. 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 temporarily available folder in the filesystem.

Remarks
The folder can actually be created and used as any other folder and will only be removed if the object is disposed of. When using this class keep in mind that access rights can change and therefore the removal of the folder might not be possible. Because the folder can be created anywhere on the filesystem and not only in the temp folder the caller should be aware that he/she first of all has to make sure the instance is disposed of and a possible remaining folder does not cause problems. Removing the folder includes everything inside that folder.
Since
0.4.0

Constructor & Destructor Documentation

◆ TemporaryFolder() [1/5]

Joutsen.IO.TemporaryFolder.TemporaryFolder ( bool  createFolder = true,
bool  removeCreatedFolders = false 
)

Creates a new folder located in the temporary folder of the local foldersystem.

Parameters
createdetermines if the folder should be created on the foldersystem together with the new instance
removeCreatedFoldersdetermines if all folders created by this instance should also be removed when this folder is removed

◆ TemporaryFolder() [2/5]

Joutsen.IO.TemporaryFolder.TemporaryFolder ( String  path,
bool  createFolder = true,
bool  removeCreatedFolders = false 
)

Creates a new folder in the location and with the name specified by.

Parameters
pathin the local foldersystem.
paththe full path to the folder including its name
createdetermines if the folder should be created on the foldersystem together with the new instance
removeCreatedFoldersdetermines if all folders created by this instance should also be removed when this folder is removed
Exceptions
ArgumentExceptionif the specified folder already exists

◆ TemporaryFolder() [3/5]

Joutsen.IO.TemporaryFolder.TemporaryFolder ( FilesystemPath  path,
bool  createFolder = true,
bool  removeCreatedFolders = false 
)

Creates a new folder in the location and with the name specified by.

Parameters
pathin the local foldersystem.
paththe full path to the folder including its name
createdetermines if the folder should be created on the foldersystem together with the new instance
removeCreatedFoldersdetermines if all folders created by this instance should also be removed when this folder is removed
Exceptions
ArgumentExceptionif the specified folder already exists

◆ TemporaryFolder() [4/5]

Joutsen.IO.TemporaryFolder.TemporaryFolder ( Folder  folder,
bool  createFolder = true,
bool  removeCreatedFolders = false 
)

Creates a new folder in the location and with the name specified by.

Parameters
path.
paththe full path to the folder including its name
createdetermines if the folder should be created on the foldersystem together with the new instance
removeCreatedFoldersdetermines if all folders created by this instance should also be removed when this folder is removed
Exceptions
ArgumentExceptionif the specified folder already exists

◆ TemporaryFolder() [5/5]

Joutsen.IO.TemporaryFolder.TemporaryFolder ( Folder  folder,
bool  removeCreatedFolders 
)
protected

Member Function Documentation

◆ CopyTo() [1/2]

Folder Joutsen.IO.TemporaryFolder.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.TemporaryFolder.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.TemporaryFolder.Create ( )

Creates the folder without content.

Implements Joutsen.IO.Folder.

◆ CreateTemporaryFolder()

TemporaryFolder Joutsen.IO.TemporaryFolder.CreateTemporaryFolder ( Folder  newFolder)
protected

◆ Delete()

void Joutsen.IO.TemporaryFolder.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.

◆ Dispose() [1/2]

void Joutsen.IO.TemporaryFolder.Dispose ( )

Removes the temporary folder if possible.

◆ Dispose() [2/2]

virtual void Joutsen.IO.TemporaryFolder.Dispose ( bool  disposing)
protectedvirtual

◆ List()

Set< FilesystemPath > Joutsen.IO.TemporaryFolder.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< File > Joutsen.IO.TemporaryFolder.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< Folder > Joutsen.IO.TemporaryFolder.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/2]

Folder Joutsen.IO.TemporaryFolder.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
Exceptions
System.ArgumentNullExceptionif dstPath is null

Implements Joutsen.IO.Folder.

◆ MoveTo() [2/2]

Folder Joutsen.IO.TemporaryFolder.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.

◆ Walk()

SCG.IEnumerable< FilesystemPath > Joutsen.IO.TemporaryFolder.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< File > Joutsen.IO.TemporaryFolder.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< Folder > Joutsen.IO.TemporaryFolder.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.

Member Data Documentation

◆ createdFolders

List<TemporaryFolder> Joutsen.IO.TemporaryFolder.createdFolders
protected

◆ folder

Folder Joutsen.IO.TemporaryFolder.folder
protected

Property Documentation

◆ CreationTime

DateTime Joutsen.IO.TemporaryFolder.CreationTime
get

The time the folder was created.

Implements Joutsen.IO.Folder.

◆ Exists

bool Joutsen.IO.TemporaryFolder.Exists
get

Checks if the folder exists in the foldersystem.

Implements Joutsen.IO.Folder.

◆ IsWritable

bool Joutsen.IO.TemporaryFolder.IsWritable
get

Checks if the folder is writable in the foldersystem.

Implements Joutsen.IO.Folder.

◆ LastModificationTime

DateTime Joutsen.IO.TemporaryFolder.LastModificationTime
get

The time the folder was last changed.

Implements Joutsen.IO.Folder.

◆ Name

String Joutsen.IO.TemporaryFolder.Name
get

The name of the folder.

Implements Joutsen.IO.Folder.

◆ Parent

Folder Joutsen.IO.TemporaryFolder.Parent
get

The folder where the folder is located.

Implements Joutsen.IO.Folder.

◆ Path

FilesystemPath Joutsen.IO.TemporaryFolder.Path
get

The path of the folder.

Implements Joutsen.IO.Folder.