<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    目錄處理函數

    Dir

    A Directory object, as well as associated functions.

    Dir.make(name)

    Creates a directory.
    創建的目錄設置為權限模式0755(八進制),這意味著它由所有者讀+寫+執行,但僅由組成員和其他人讀+執行。

    如果成功創建了目錄,則返回布爾值true。如果由于目錄已經存在而無法創建該目錄,則返回false。如果由于發生錯誤而無法創建目錄,則返回nil。

    Arguments

    name

    The name of the directory, possibly including path.

    Returns

    Boolean true on success, false if the directory already exists, nil on error.

    Dir.exists(name)

    如果給定的目錄名存在,則返回true。
    如果該目錄存在,則返回布爾值true。如果路徑是文件,則返回false。如果路徑不存在或發生錯誤,則返回nil。

    Arguments

    name
    The name of the directory, possibly including path.

    Returns

    Boolean true if the directory exists, false if it’s a file, nil on error or not-exist.

    Dir.remove(name)

    刪除一個空目錄。

    如果目錄被成功刪除,將返回一個布爾值true。如果由于目錄不存在而無法刪除該目錄,則返回false。如果由于發生錯誤而無法刪除該目錄,則返回nil。

    此函數僅刪除空目錄。無論如何要刪除一個目錄,請使用Dir.remove_all()。

    Arguments

    name

    The name of the directory, possibly including path.

    Returns

    Boolean true on success, false if does not exist, nil on error.

    Dir.remove_all(name)

    刪除空目錄或非空目錄。

    如果目錄被成功刪除,將返回一個布爾值true。如果由于目錄不存在而無法刪除該目錄,則返回false。如果由于發生錯誤而無法刪除該目錄,則返回nil。

    Arguments

    name

    The name of the directory, possibly including path.

    Returns

    Boolean true on success, false if does not exist, nil on error.

    Dir.open(pathname, [extension])

    打開一個目錄并返回一個表示該目錄中的文件的Dir對象。

     -- Print the contents of a directory
        for filename in Dir.open('/path/to/dir') do
                print(filename)
        end
    Arguments

    pathname

    The pathname of the directory.

    extension (optional)

    If given, only files with this extension will be returned.

    Returns

    The Dir object.

    Dir.personal_config_path([filename])

    獲取個人配置目錄路徑,如果提供了文件名。

    Arguments

    filename (optional)

    A filename.

    Returns

    The full pathname for a file in the personal configuration directory.

    Dir.global_config_path([filename])

    獲取全局配置目錄路徑,如果提供了文件名。

    Arguments

    filename (optional)

    A filename

    Returns

    The full pathname for a file in Wireshark’s configuration directory.

    Dir.personal_plugins_path()

    Gets the personal plugins directory path.

    Returns

    The pathname of the personal plugins directory.

    Dir.global_plugins_path()

    Gets the global plugins directory path.

    Returns

    The pathname of the global plugins directory.

    dir:__call()

    Gets the next file or subdirectory within the directory, or nil when done.

    -- Open a directory and print the name of the first file or subdirectory
        local dir = Dir.open('/path/to/dir')
        local first = dir()
        print(tostring(file))

    dir:close()

    關閉目錄。在對Dir對象進行垃圾收集時自動調用。

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类