/*!
Stores the current package definition file to the directory \a $path.
193355
function storePackageFile( $path, $storeCache = true )
    {
        if ( !file_exists( $path ) )
        {
            eZDir::mkdir( $path, false, true );
        }
        $filePath = $path . '/' . eZPackage::definitionFilename();

        $packageFileString = $this->toString();
        $result = $this->storeString( $filePath, $packageFileString );

        if ( $storeCache )
            $this->storeCache( $path . '/' . $this->cacheDirectory() );
        return $result;
    }
166098
public function guessPackagePath()
    {
        $reflection = new ReflectionClass($this);

        $path = $reflection->getFileName();

        return realpath(dirname($path) .'/../');
    }
255878
public function pathToEntity($path)
    {
        return is_dir($path) ? new FileSystem\Directory($path) : new FileSystem\File($path);
    }
1363269
public function save($path = null)
    {
        if (!is_null($path)) {
            $this->path = $path;
        }

        if (!is_dir($path = $this->getDestinationDirectory())) {
            File::makeDirectory($path, 0777, true);
        }

        $this->image->save($this->getDestinationFile());

        return $this->filename;
    }
198439
function Project(path) {
  path = path || PWD;
  this.root = '';
  this.storage = '';
  this.ignore = [];
  this.resolvePaths(path);
}
1336871
public function compile( $path = null )
	{
		if ( $path )
			$this->setPath( $path );

		if ( !is_null( $this->cachePath ) )
		{
			$contents = $this->compileString( $this->files->get( $this->getPath() ) );
			$this->files->put( $this->getCompiledPath( $this->getPath() ), $contents );
		}
	}
405513
public function autodiscover($path)
    {
        if (!is_array($path)) {
            $path = (array) $path;
        }

        foreach ($path as $apps_dir) {

            if (is_dir($apps_dir)) {

                if (($dh = opendir($apps_dir)) !== false) {

                    while (($name = readdir($dh)) !== false) {

                        if ($name{0} == '.' || $name == 'Core' || is_file($apps_dir . '/' . $name)) {
                            continue;
                        }

                        $app = $this->getAppInstance($name);
                    }

                    closedir($dh);
                }
            }
        }
    }
314331
function filePersister(filepath) {

	var self = this;
	this.initialized = false;
	this.filepath = filepath;

	/**
	 * Check to see if the specified file path is available.
	 * @returns A promise appropriately resolving or rejecting.
	 */
	this.start = function() {
		if (!this.initialized) {
			return fsp.emptyDir(this.filepath)
			.then(function() {
				self.initialized = true;
				return Promise.resolve('User has permissions to write to that file.');
			})
			.catch(function(err) {
				return Promise.reject('User does not have permissions to write to that folder.');
			});
		}
		return Promise.reject('Error: Persister already initialized.');
	};

	/**
	 * Save the passed state to the file.
	 * @param {Object} passedState - State to be saved in the file.
	 * @returns A promise resolving to an appropriate success message or an error message.
	 */
	this.save = function(brain, package) {
		var filepath = this.filepath;
		if (this.initialized) {
			return fsp.remove(filepath + '/' + package + '.txt')
			.then(function(){
				return fsp.writeFile(filepath + '/' + package + '.txt', JSON.stringify(brain));				
			})
			.then(function(){
				return Promise.resolve('Saved.');
			})
		} 
		return Promise.reject('Error: Persister not initialized.');
	};

	/**
	 * Retrieve data from the file.
	 * @returns The most recent entry to the file, as a JavaScript object.
	 */
	this.recover = function(package) {
		if (this.initialized) {
			var filepath = this.filepath
			return fsp.ensureFile(filepath +'/' + package + '.txt')
			.then(function(){
				return fsp.readFile(filepath + '/' + package + '.txt', 'utf8')
			})
			.then(function(data) {
				if (data === ''){
					return Promise.resolve({});
				} else {
					return Promise.resolve(JSON.parse(data));
				}
			});
		}
		return Promise.reject('Error: Persister not initialized.');
	};

}
650499
function _setDirectoryOpen(treeData, path, open) {
        var objectPath = _filePathToObjectPath(treeData, path),
            directory = treeData.getIn(objectPath);

        if (!objectPath) {
            return {
                needsLoading: true,
                treeData: treeData
            };
        }

        if (isFile(directory)) {
            return;
        }

        var alreadyOpen = directory.get("open") === true;

        if ((alreadyOpen && open) || (!alreadyOpen && !open)) {
            return;
        }

        treeData = treeData.updateIn(objectPath, function (directory) {
            if (open) {
                return directory.set("open", true);
            } else {
                return directory.delete("open");
            }
        });

        if (open && (directory.get("children") === null || directory.get("notFullyLoaded"))) {
            return {
                needsLoading: true,
                treeData: treeData
            };
        }
        return {
            needsLoading: false,
            treeData: treeData
        };
    }
137724
function fileMove( $srcPath, $dstPath )
    {
        eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileMove( '$srcPath', '$dstPath' )", __METHOD__ );

        eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
        eZFile::rename( $srcPath, $dstPath, true );
        eZDebug::accumulatorStop( 'dbfile' );
    }
1368760
function (path) {
    var pathSep = require('path').sep;
    var dirs = path.split(pathSep);
    var root = '';

    while (dirs.length > 0) {
      var dir = dirs.shift();
      if (dir === '') {
        root = pathSep;
      }
      if (!fs.existsSync(root + dir)) {
        fs.mkdirSync(root + dir);
      }
      root += dir + pathSep;
    }
  }
1205412
function is_dir($path) {

        // be sure path is utf-8
        $item = $this->gpi($path);

        if ($item === false) {
            return false;
        } else {
            return ($item['resourcetype'] == 'collection');
        }
    }
1318872
public function setRootDirectory($path)
    {
        if (@file_exists($path) && is_dir($path)) {
            $this->_root_dir = $path;
        } else {
            throw new InvalidArgumentException(
                sprintf('Root package directory "%s" not found !', $path)
            );
        }
        return $this;
    }
435576
function storeFileToDisk(i_oFile, i_sOutput) {
    var l_sDirname = path.dirname(i_oFile.filename),
        l_sFilename;

    console.log("File name: ", i_oFile.filename, " size: ", i_oFile.header.unpackedSize);
    console.log("Saving content of file ");

    l_sDirname = path.join(i_sOutput, path.dirname(i_oFile.filename));
    l_sFilename = path.join(l_sDirname, path.basename(i_oFile.filename));
    return new Promise(function(i_oResolve) {
        mkdirp(l_sDirname, function (err) {
            if (err) console.error(err);
            _writeFile(l_sFilename, i_oFile, i_oResolve);
        });
    });
}
1059771
function move( $dstPath )
    {
        $dstPath = self::cleanPath( $dstPath );
        $srcPath = $this->filePath;

        eZDebugSetting::writeDebug( 'kernel-clustering', "dfs::fileMove( '$srcPath', '$dstPath' )" );

        self::$dbbackend->_rename( $srcPath, $dstPath );

        $this->metaData = null;
    }
38563
function appendSimpleFile( $key, $filepath )
    {
        if ( !isset( $this->Parameters['simple-file-list'] ) )
        {
            $this->Parameters['simple-file-list'] = array();
        }

        $suffix = eZFile::suffix( $filepath );
        //$sourcePath = $fileInfo['original-path'];
        $packagePath = eZPackage::simpleFilesDirectory() . '/' . substr( md5( mt_rand() ), 0, 8 ) . '.' . $suffix;
        $destinationPath = $this->path() . '/' . $packagePath;
        eZDir::mkdir( eZDir::dirpath( $destinationPath ), false, true );

       //SP DBfile
        $fileHandler = eZClusterFileHandler::instance();
        $fileHandler->fileFetch( $filepath );

        eZFileHandler::copy( $filepath, $destinationPath );

        $this->Parameters['simple-file-list'][$key] = array( 'original-path' => $filepath,
                                                             'package-path' => $packagePath );
    }
644410
function is_dir($path)
    {
        $result = $this->_get_stat_cache_prop($path, 'type');
        if ($result === false) {
            return false;
        }
        return $result === NET_SFTP_TYPE_DIRECTORY;
    }