function createFileIndex($dirToIndex, $indexLocation)
    {
        # 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.
        if ($dirToIndex == $indexLocation)
        {
            $errMsg = 'Cannot place index in same folder being indexed!';
            throw new \Exception($errMsg);
        }

        # delete the old index if one already exists.
        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))
            {
                # create the placement directory if it doesn't exist already
                mkdir($placement_dir);

                $newPath = $placement_dir . "/" . $filename;
                
                if (!is_link($newPath)) 
                {
                    symlink($dirToIndex . '/' . $filename, $newPath);
                }
            }
        }
    }