Giter Club home page Giter Club logo

dir's Introduction

Dir - Directory Scanner

Build Status Code Coverage

Dir is a small library which allows to perform some recursive operations on directories.

Dir::scan()

Gets all nested directories and/or files present inside a directory.

$files = Dir::scan('my/dir',       // Can be a string path of an array of string paths
    [
        'include' => '*.txt',      // Can be an array of includes
        'exclude' => '*.save.txt', // Can be an array of excludes
        'type'    => 'file'        // Can be an array of types, possible values:
                                   // `'file'`, `'dir'`, `'executable'`, `'link'`, `'readable'`, `'writable'`
        'skipDots'       => true,  // Keeps '.' and '..' directories in result
        'leavesOnly'     => true,  // Keeps only leaves
        'followSymlinks' => true,  // Follows Symlinks
        'recursive'      => true   // Scans recursively,
        'copyHandler'    => function($path, $target) { // The copy handler
            copy($path, $target);
        }
    ]
);

Dir::copy()

Copies a directory with files recursively into a destination folder.

$files = Dir::copy('my/dir',       // A string path of an array of string paths
    'my/destination',              // A destination path (string only)
    [
        'mode'           => 0755,  // Mode used for directory creation
        'childrenOnly'   => false, // Copies the file inside 'my/dir' if `true`, otherwise `dir` will be
                                   // added as the root directory.
        'followSymlinks' => true,  // Follows Symlinks
        'recursive'      => true   // Scans recursively
    ]
);

Dir::remove()

Removes a directory and all its content recursively.

Dir::remove('my/dir',     // Can be a string path of an array of string paths
    [
        'followSymlinks' => false,        // Follows Symlinks
        'recursive'      => true,         // Scans recursively
        'include'        => '*.txt',      // Can be an array of includes
        'exclude'        => '*.save.txt', // Can be an array of excludes
    ]
);

Dir::make()

Makes nested directories.

$success = Dir::make('my/dir',  // Can be a string path of an array of string paths
    [
        'mode'      => 0755,         // Mode used for directory creation
        'recursive' => true,         // Scans recursively
        'include'   => '*.txt',      // Can be an array of includes
        'exclude'   => '*.save.txt', // Can be an array of excludes
    ]
);

Dir::tempnam()

Creates a temporary folder (like the tempnam() function but for directories).

$dir = Dir::tempnam(sys_get_temp_dir(), 'mytmp');

dir's People

Contributors

jails avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.