Item INTERFACE

A file system item. Can be a file or directory.

When using this and other FS APIs, it's common to deal with paths. Unless noted, a path can be either absolute or relative (to working directory of the current process). A path comprises of one or more sections, and in case of relative path the path can be even empty. These section are separated by a path separator, which can differ based on the OS. However, Julian recognizes both '/' (POSIX) and '' (Windows) as the equally legal path separator.

Known Extensions

All Members


TypeNameSignature
methodcreatepublic bool create()
methoddeletepublic bool delete()
methodexistspublic bool exists()
methodgetNamepublic String getName()
methodgetPathpublic String getPath()
methodisFilepublic bool isFile()
methodmovepublic bool move(System.IO.Directory)
methodrenamepublic bool rename(string)
method Erelocatepublic bool relocate(System.IO.Directory, string)

Methods


public bool create()

Create this item.

Returns

  • true if the item was successfully created.

public bool delete()

Delete this item.

Returns

  • true if the item was successfully deleted; false if the item either didn't exist, or encountered an IO error.

public bool exists()

Whether this item exist on file system.

Returns

  • true if the item exists.

public String getName()

Get the name of this item. This is only the simple name (with extension part) under the path.

Returns

  • the simple name of this item.

public String getPath()

Get the absolute path of this item. This doesn't include the name.

Returns

  • the absolute path under which this item resides.

public bool isFile()

Whether this item is a file

Returns

  • true if the item is a file; false a directory.

public bool move(Directory newDir)

Move this item to another directory.

Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Rename operation is only for renaming without moving around the file, while this method may only be used to move an item from one directory to another without changing its name. The obvious implication of this division is that for the move operation, the destination must be a valid directory, and there must be no item in that directory that is already possessing the same name. In any of these cases this method returns false. Moving to the same directory is allowed and implemented trivially by returning true directly.

To move an item and change its name, use extension method relocate().

Parameters

  • newDir The new directory.

Returns

  • True if the item was successfully moved; false if it couldn't be.

Throws


public bool rename(string newName)

Rename this item while remaining in the same directory.

Unlike a few file systems where the move command/API serves dual purpose, Julian splits the semantics between move and rename. Move operation may only be used to move an item from one directory to another without changing its name, while this method is only for renaming without moving around the file. The obvious implication of this division is that for the rename operation, the new name must not contain file system separator, and there must be no item within the same directory that is already possessing the same name. In any of these cases this method returns false.

To move an item and change its name, use extension method relocate().

Parameters

  • newName The new item name. Must not contain FS separator.

Returns

  • True if the item was successfully renamed; false if it couldn't be.

Throws