public static function autoclean($path, $time = -1)
    {
        $path = self::resolve($path);

        if ($path !== false && is_dir($path) && ($dh = opendir($path))) {
            if ($time < 0) {
                $time = App::env('appdata_expires');
            }

            $expires = REQUEST_TIME - $time;
            $path .= '/';

            while (false !== ($file = readdir($dh))) {
                $current = $path . $file;

                if (is_file($current) && filemtime($current) < $expires) {
                    unlink($current);
                }
            }

            closedir($dh);

            $dh = null;
        }
    }