This class will handle common sequences of node I/O and issue messages / throw errors as neccessary.

export

### Hierarchy

- IO

## Index

### Properties

- FILE_DELIM
- OS_LINUX
- OS_MAC
- OS_WIN32
- UTF8

### Methods

- createDirSync
- createDirsSync
- createDirsSyncFromFilePath
- createFileSync
- createReadStream
- createSymlinkToDir
- createWriteStream
- deleteDir
- deleteDirTree
- deleteFile
- deleteSymLink
- existsSync
- getDefaultTextEditor
- giveAccessOnlyToOwner
- isDir
- mkdirp
- normalizeExtension
- processNewlines
- readFileSync
- writeFile
- writeFileAsync
- writeObject

## Properties

### Static Readonly FILE_DELIM

FILE_DELIM: string = path.posix.sep

- Defined in @zowe/imperative/src/io/src/IO.ts:37

File delimiter

deprecated

  Use `path.posix.sep` instead or `path.sep` for better cross-platform support

static
memberof

  IO

### Static Readonly OS_LINUX

OS_LINUX: "linux" = "linux"

- Defined in @zowe/imperative/src/io/src/IO.ts:65

Linux OS identifier

static
memberof

  IO

### Static Readonly OS_MAC

OS_MAC: "darwin" = "darwin"

- Defined in @zowe/imperative/src/io/src/IO.ts:58

Mac OS identifier

static
memberof

  IO

### Static Readonly OS_WIN32

OS_WIN32: "win32" = "win32"

- Defined in @zowe/imperative/src/io/src/IO.ts:51

Windows OS identifier

static
memberof

  IO

### Static Readonly UTF8

UTF8: "utf8" = "utf8"

- Defined in @zowe/imperative/src/io/src/IO.ts:44

UTF8 identifier

static
memberof

  IO

## Methods

### Static createDirSync

- createDirSync(dir: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:117

  Create a directory and all subdirectories if they do not yet exist synchronously.

  static
  memberof

    IO

  #### Parameters

  - ##### dir: string

    directory to create

  #### Returns void

### Static createDirsSync

- createDirsSync(dir: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:131

  Create all needed directories for an input directory in the form of: first/second/third where first will contain director second and second will contain directory third

  static
  memberof

    IO

  deprecated

    Please use IO.createDirSync

  #### Parameters

  - ##### dir: string

    directory to create all sub directories for

  #### Returns void

### Static createDirsSyncFromFilePath

- createDirsSyncFromFilePath(filePath: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:144

  Create all necessary directories for a fully qualified file and its path, for example, if filePath = oneDir/twoDir/threeDir/file.txt, oneDir, twoDir, and threeDir will be created.

  static
  memberof

    IO

  #### Parameters

  - ##### filePath: string

  #### Returns void

  [description]

### Static createFileSync

- createFileSync(file: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:314

  Create a file

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

    file to create

  #### Returns void

### Static createReadStream

- createReadStream(file: string): Readable

- - Defined in @zowe/imperative/src/io/src/IO.ts:231

  Create a Node.js Readable stream from a file

  memberof

    IO

  #### Parameters

  - ##### file: string

    the file from which to create a read stream

  #### Returns Readable

  Buffer - the content of the file

### Static createSymlinkToDir

- createSymlinkToDir(newSymLinkPath: string, existingDirPath: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:156

  Create a symbolic link to a directory. If the symbolic link already exists, re-create it with the specified target directory.

  #### Parameters

  - ##### newSymLinkPath: string

    the path new symbolic link to be created

  - ##### existingDirPath: string

    the path the existing directory that we will link to

  #### Returns void

### Static createWriteStream

- createWriteStream(file: string): Writable

- - Defined in @zowe/imperative/src/io/src/IO.ts:242

  Create a Node.js Readable stream from a file

  memberof

    IO

  #### Parameters

  - ##### file: string

    the file from which to create a read stream

  #### Returns Writable

  Buffer - the content of the file

### Static deleteDir

- deleteDir(dir: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:441

  Delete a directory

  static
  memberof

    IO

  #### Parameters

  - ##### dir: string

  #### Returns void

### Static deleteDirTree

- deleteDirTree(pathToTreeToDelete: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:453

  Recursively delete all files and subdirectories of the specified directory. Ensure that we do not follow a symlink. Just delete the link.

  params

    {string} pathToTreeToDelete - Path to top directory of the tree to delete.

  #### Parameters

  - ##### pathToTreeToDelete: string

  #### Returns void

### Static deleteFile

- deleteFile(file: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:428

  Delete a file

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

  #### Returns void

### Static deleteSymLink

- deleteSymLink(symLinkPath: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:487

  Delete a symbolic link.

  #### Parameters

  - ##### symLinkPath: string

    the path to a symbolic link to be deleted

  #### Returns void

### Static existsSync

- existsSync(file: string): boolean

- - Defined in @zowe/imperative/src/io/src/IO.ts:105

  Wraps fs.existsSync so that we dont have to import fs unnecessarily

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

    file to validate existence against

  #### Returns boolean

  true if file exists

### Static getDefaultTextEditor

- getDefaultTextEditor(): string

- - Defined in @zowe/imperative/src/io/src/IO.ts:297

  Get default text editor for a given operating system

  static
  memberof

    IO

  #### Returns string

  - text editor launch string

### Static giveAccessOnlyToOwner

- giveAccessOnlyToOwner(fileName: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:329

  Set file access permissions so that only the current user will have access to the file. On windows, it means "full control" for the current user. On posix, it means read & write access for the current user. Obviously, the current user must have permission to change permissions on the specified file.

  throws

    An ImperativeError when the operation fails.

  #### Parameters

  - ##### fileName: string

    file name for which we modify access.

  #### Returns void

### Static isDir

- isDir(dirOrFile: string): boolean

- - Defined in @zowe/imperative/src/io/src/IO.ts:74

  Return whether input file is a directory or file

  static
  memberof

    IO

  #### Parameters

  - ##### dirOrFile: string

    file path

  #### Returns boolean

  - true if file path is a directory, false otherwise

### Static mkdirp

- mkdirp(dir: string): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:195

  Create a directory and all subdirectories if they do not yet exist synchronously.

  static
  memberof

    IO

  deprecated

    Please use IO.createDirSync

  #### Parameters

  - ##### dir: string

    the directory (do not include a file name)

  #### Returns void

### Static normalizeExtension

- normalizeExtension(extension: string): string

- - Defined in @zowe/imperative/src/io/src/IO.ts:87

  Take an extension and prefix with a '.' identifier

  static
  memberof

    IO

  #### Parameters

  - ##### extension: string

    extension to normalize

  #### Returns string

  - '.bin' for input 'bin' for example

### Static processNewlines

- processNewlines<T>(original: T, lastByte?: number): T

- - Defined in @zowe/imperative/src/io/src/IO.ts:257

  Process a string so that its line endings are operating system appropriate before you save it to disk (basically, if the user is on Windows, change \n to \r\n)

  static
  memberof

    IO

  #### Type parameters

  - #### T: string | Buffer

  #### Parameters

  - ##### original: T

    original input

  - ##### Optional lastByte: number

    last byte of previous input, if it is being processed in chunks

  #### Returns T

  - input with removed newlines

### Static readFileSync

- readFileSync(file: string, normalizeNewLines?: boolean, binary?: boolean): Buffer

- - Defined in @zowe/imperative/src/io/src/IO.ts:211

  Wraps fs.readFileSync so that we dont have to import fs unnecessarily or specify encoding.

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

    file to read

  - ##### Default value normalizeNewLines: boolean = false

    remove Windows line endings (\r\n) in favor of \n

  - ##### Default value binary: boolean = false

    should the file be read in binary mode? If so, normalizeNewLines is ignored. If false, the file will be read in UTF-8 encoding

  #### Returns Buffer

  Buffer - the content of the file

### Static writeFile

- writeFile(file: string, content: Buffer): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:391

  Write a file

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

    file to create

  - ##### content: Buffer

    content to write

  #### Returns void

### Static writeFileAsync

- writeFileAsync(file: string, content: string): Promise<void>

- - Defined in @zowe/imperative/src/io/src/IO.ts:370

  Create a file asynchronously

  static
  memberof

    IO

  #### Parameters

  - ##### file: string

    file to create

  - ##### content: string

    content to write in the file

  #### Returns Promise<void>

  [description]

### Static writeObject

- writeObject(configFile: string, object: object): void

- - Defined in @zowe/imperative/src/io/src/IO.ts:411

  Write an object to a file and set consistent formatting on the serialized JSON object.

  static
  memberof

    IO

  #### Parameters

  - ##### configFile: string

    file to create

  - ##### object: object

    object to serialize

  #### Returns void

Generated using TypeDoc