src/Filesystem.php
/**
     * Creates an index of the files in the specified directory, by creating 
     * symlinks to them, which are separated into folders having the first 
     * letter.
     * WARNING - this will only index files that start with alphabetical 
     * characters.
     * @param string $dirToIndex - the directory we wish to index.
     * @param string $indexLocation - where to stick the index.
     * @return void
     */
Creates an index of the files in the specified directory, by creating
symlinks to them, which are separated into folders having the first
letter.
WARNING - this will only index files that start with alphabetical
characters.
@param string $dirToIndex - the directory we wish to index.
@param string $indexLocation - where to stick the index.
@return void
Creates an index of the files in the specified directory by creating symlinks to them which are separated into folders having the first letter . WARNING - this will only index files that start with alphabetical characters . @param string $dirToIndex - the directory we wish to index . @param string $indexLocation - where to stick the index . @return void
function createFileIndex($dirToIndex, $indexLocation)
    {
        if ($dirToIndex == $indexLocation)
        {
            $errMsg = 'Cannot place index in same folder being indexed!';
            throw new \Exception($errMsg);
        }
        if (file_exists($indexLocation))
        {
            self::deleteDir($indexLocation);
        }
        if (!mkdir($indexLocation))
        {
            $err = 'Failed to create index directory, check write permissions';
            throw new \Exception($err);
        }
        $files = scandir($dirToIndex);
        foreach ($files as $filename) 
        {
            $first_letter = $filename[0];
            $placement_dir = $indexLocation . "/" . strtoupper($first_letter);
            if (ctype_alpha($first_letter))
            {
                mkdir($placement_dir);
                $newPath = $placement_dir . "/" . $filename;
                if (!is_link($newPath)) 
                {
                    symlink($dirToIndex . '/' . $filename, $newPath);
                }
            }
        }
    }
function createFileIndex ( $ dirToIndex , $ indexLocation ) { if ( $ dirToIndex == $ indexLocation ) { $ errMsg = 'Cannot place index in same folder being indexed!' ; throw new \ Exception ( $ errMsg ) ; } if ( file_exists ( $ indexLocation ) ) { self :: deleteDir ( $ indexLocation ) ; } if ( ! mkdir ( $ indexLocation ) ) { $ err = 'Failed to create index directory, check write permissions' ; throw new \ Exception ( $ err ) ; } $ files = scandir ( $ dirToIndex ) ; foreach ( $ files as $ filename ) { $ first_letter = $ filename [ 0 ] ; $ placement_dir = $ indexLocation . " / " . strtoupper ( $ first_letter ) ; if ( ctype_alpha ( $ first_letter ) ) { mkdir ( $ placement_dir ) ; $ newPath = $ placement_dir . " / " . $ filename ; if ( ! is_link ( $ newPath ) ) { symlink ( $ dirToIndex . '/' . $ filename , $ newPath ) ; } } } }
Creates an index of the files in the specified directory, by creating
 symlinks to them, which are separated into folders having the first
 letter.
Creates an index of the files in the specified directory by creating symlinks to them which are separated into folders having the first letter .
# Don't let the user place the index in the same folder being indexed,  # otherwise the directory cannot be re-indexed later, otherwise we will  # be indexing the index. # delete the old index if one already exists. # create the placement directory if it doesn't exist already