📜  PhantomJS-文件系统模块方法

📅  最后修改于: 2020-10-21 05:36:33             🧑  作者: Mango


下表列出了所有方法及其说明,这些方法及其说明在文件系统模块上可用。

S.No Methods & Description
1 absolute

This method gives the absolute path where PhantomJS runs.

2 changeWorkingDirectory

This allows you to change the working directory and returns true, if it succeeds otherwise returns false.

3 copyTree

copyTree will copy a directory from one path to another. The first parameter is a source folder and the second parameter is a destination folder.

4 copy

This method helps to copy file from one location to another. It takes two parameters. The first parameter is the source file and the second parameter is the file path, where it has to be copied. It will throw an error, if the source or destination file does not exist.

5 exists

It checks whether the given file path exists in the system. It returns true, if it is present, otherwise false.

6 isAbsolute

This method will return true, if the file path is absolute and false, if relative.

7 isDirectory

isDirectory tells if the given file is a directory or not. It returns true, if directory otherwise false. It gives false in case if the given path does not exist.

8 isExecutable

This method will tell if the given file is executable or not. It returns true, if executable, otherwise false.

9 isFile

This gives details whether the filepath given is a file or not. It returns true, if it is a file and false, if it is not.

10 isLink

This will give you true, if the file path is a symlink, otherwise false.

11 isReadable

It checks if the given file is readable or not. It gives true, if yes and false, if not.

12 isWritable

It tells whether if a given file is writable. Returns true, if yes, otherwise false.

13 lastModified

Gives the details of the last modification done to the file. It tells the date and time of when the file was last modified.

14 list

It gives all the files present in the directory.

15 makeDirectory

Creates a new directory.

16 makeTree

makeTree creates all necessary folders to be able to form final directories. This will return true, if the creation was successful, otherwise false. If the directory already exists, it will return true.

17 move

It will move the file from one path to another.

18 open

It is used to open up the file.

19 readLink

This will return the absolute path of a file or a folder pointed by a symlink (or shortcut on Windows). If the path is not a symlink or shortcut, it will return an empty string.

20 read

This will read the given file.

21 removeDirectory

This will remove the given directory.

22 removeTree

It will delete all the files and folders from the given folder and finally delete the folder itself. If there is any error while doing this process, it will throw an error – ‘Unable to remove directory tree PATH’ and hang execution.

23 remove

It removes the given file.

24 size

It gives the size of the file.

25 touch

It creates a given file.

26 write

Writes to a given file.