public static function uniqueFilename($basepath, $prefix = '', $suffix = '')
    {
        /* We're using a long 30 character random filename. That means we
           can have 4.48755316e+23 permutations. */
        $filename = $prefix;

        while($filename == $prefix || file_exists(self::joinPaths($basepath, $filename))) {
            for($charnum = 0; $charnum < 30; $charnum++) {
                $ascii = 48 + rand(0, 60);
                if($ascii > 57) $ascii+= 7; // Realigning on A
                if($ascii > 90) $ascii+= 7; // Realigning on a
                $filename.= chr($ascii);
            }
            $filename.= $suffix;
        }

        $filename = self::joinPaths($basepath, $filename);

        /* We touch the file to make sure the filename won't be
           used before we save to it. */
        touch($filename);

        return $filename;
    }