#

API Docs for: 0.3.17
Show: Inherited Protected Private Deprecated

# Files Class

Defined in: `lib/files.js:3`
Module: yuidoc

Ported fileutils methods from Selleck

- Index
- Methods

## Item Index

### Methods

- copyAssets
- copyDirectory
- copyFile
- copyPath
- deletePath
- getJSON
- isDirectory
- isFile
- isSymbolicLink
- lstatSync
- statSync
- writeFile

## Methods

### `copyAssets`

(

- `from`
- `dest`
- `deleteFirst`
- `callback`

)

Defined in `lib/files.js:336`

Copy the theme assets directory

#### Parameters:

- `from` Path

  The source directory

- `dest` Path

  The destination directory

- `deleteFirst` Boolean

  Should the directory be deleted if it exists

- `callback` Function

  The callback to be executed

### `copyDirectory`

(

- `source`
- `dest`
- `[overwrite=false]`
- `callback`

)

Defined in `lib/files.js:37`

Copy a directory from one location to another

#### Parameters:

- `source` Path

  The source directory

- `dest` Path

  The destination directory

- `[overwrite=false]` Boolean optional

  Whether or not to overwrite destination files if they already exist.

- `callback` Function

  The callback to be executed when complete.

### `copyFile`

(

- `source`
- `dest`
- `[overwrite=false]`
- `callback`

)

Defined in `lib/files.js:114`

Copy a file from one location to another

#### Parameters:

- `source` Path

  The source file

- `dest` Path

  The destination file

- `[overwrite=false]` Boolean optional

  Whether or not to overwrite destination files if they already exist.

- `callback` Callback

  The callback to be executed when complete.

  - `err` Error

    The Error returned from Node

### `copyPath`

(

- `source`
- `dest`
- `[overwrite=false]`
- `callback`

)

Defined in `lib/files.js:157`

If source is a file, copies it to dest. If it's a directory, recursively copies it and all files and directories it contains to dest.

Note that when attempting to copy a file into a directory, you should specify the full path to the new file (including the new filename). Otherwise, it will be interpreted as an attempt to copy the source file over the dest directory instead of into it.

Known issues: - Doesn't preserve ownership or permissions on copied files/directories.

#### Parameters:

- `source` String

  Source path.

- `dest` String

  Destination path.

- `[overwrite=false]` Boolean optional

  Whether or not to overwrite destination files if they already exist.

- `callback` Callback

  The callback to execute when completed.

  - `err` Error

### `deletePath`

(

- `path`

)

Defined in `lib/files.js:204`

If path is a file, deletes it. If path is a directory, recursively deletes it and all files and directories it contains.

This method is synchronous.

#### Parameters:

- `path` String

  File or directory to delete.

### `getJSON`

(

- `filename`

)
Object

Defined in `lib/files.js:384`

Helper method for getting JSON data from a local file

#### Parameters:

- `filename` Path

  The filename to parse JSON from

#### Returns:

Object: The JSON data

### `isDirectory`

(

- `path`
- `[link=false]`

)
Boolean

Defined in `lib/files.js:228`

Check to see if this is a directory

#### Parameters:

- `path` Path

  The path to check

- `[link=false]` Boolean optional

  Also validate a symlink

#### Returns:

Boolean: True if it is a directory

### `isFile`

(

- `path`
- `[link=false]`

)
Boolean

Defined in `lib/files.js:256`

Check to see if this is a File

#### Parameters:

- `path` Path

  The path to check

- `[link=false]` Boolean optional

  Also validate a symlink

#### Returns:

Boolean: True if it is a file

### `isSymbolicLink`

(

- `path`

)
Boolean

Defined in `lib/files.js:282`

Check to see if this is a SymLink

#### Parameters:

- `path` Path

  The path to check

#### Returns:

Boolean: True if it is a link

### `lstatSync`

(

- `path`

)
fs.Stats | Null

Defined in `lib/files.js:294`

Like `fs.lstatSync()`, but returns `null` instead of throwing when path doesn't exist. Will still throw on other types of errors.

#### Parameters:

- `path` String

  Path to stat.

#### Returns:

fs.Stats | Null: `fs.Stats` object, or `null` if path doesn't exist.

### `statSync`

(

- `path`

)
fs.Stats | Null

Defined in `lib/files.js:315`

Like `fs.statSync()`, but returns `null` instead of throwing when path doesn't exist. Will still throw on other types of errors.

#### Parameters:

- `path` String

  Path to stat.

#### Returns:

fs.Stats | Null: `fs.Stats` object, or `null` if path doesn't exist.

### `writeFile`

(

- `file`
- `data`
- `callback`

)

Defined in `lib/files.js:398`

Helper method for writing files to disk. It wraps the NodeJS file API

#### Parameters:

- `file` Path

  The filename to write to

- `data` String

  The data to write

- `callback` Callback multiple