function actionDefault() { YDDebugUtil::dump(YDPath::getDirectorySeparator(), 'getDirectorySeparator()'); YDDebugUtil::dump(YDPath::getPathSeparator(), 'getPathSeparator()'); YDDebugUtil::dump(YDPath::getVolumeSeparator(), 'getVolumeSeparator()'); YDDebugUtil::dump(YDPath::changeExtension(__FILE__, '.tpl'), 'changeExtension( __FILE__, ".tpl" )'); YDDebugUtil::dump(YDPath::getDirectoryName(__FILE__), 'getDirectoryName( __FILE__ )'); YDDebugUtil::dump(YDPath::getExtension(__FILE__), 'getExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFileName(__FILE__), 'getFileName( __FILE__ )'); YDDebugUtil::dump(YDPath::getFileNameWithoutExtension(__FILE__), 'getFileNameWithoutExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFilePath(__FILE__), 'getFilePath( __FILE__ )'); YDDebugUtil::dump(YDPath::getFilePathWithoutExtension(__FILE__), 'getFilePathWithoutExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFullPath(__FILE__), 'getFullPath( __FILE__ )'); YDDebugUtil::dump(YDPath::getTempFileName(), 'getTempFileName()'); YDDebugUtil::dump(YDPath::getTempPath(), 'getTempPath()'); YDDebugUtil::dump(YDPath::hasExtension(__FILE__), 'hasExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::hasExtension(YDPath::getFileNameWithoutExtension(__FILE__)), 'hasExtension( YDPath::getFileNameWithoutExtension( __FILE__ ) )'); YDDebugUtil::dump(YDPath::isAbsolute(__FILE__), 'isAbsolute( __FILE__ )'); YDDebugUtil::dump(YDPath::isAbsolute(YDPath::getFileName(__FILE__)), 'isAbsolute( getFileName( __FILE__ ) )'); YDDebugUtil::dump(YDPath::join(__FILE__), 'join( __FILE__ )'); YDDebugUtil::dump(YDPath::join(YDPath::getTempPath(), YDPath::getFileName(__FILE__)), 'join( getTempPath(), getFileName( __FILE__ ) )'); YDDebugUtil::dump(YDPath::join(YDPath::getTempPath(), __FILE__), 'join( getTempPath(), __FILE__ )'); }
/** * This function will save the XML data to the specified file. * * @remark * The default format is "RSS2.0". If you specify no argument indicating the requested format, the "RSS2.0" * format will be used. * * @param $path The path to save the XML data to. * @param $format (optional) The format in which the items should be converted. */ function saveXml($path, $format = 'RSS2.0') { // Get the XML data $xml = $this->toXml($format); // Get the directory information $dir = new YDFSDirectory(YDPath::getDirectoryName($path)); // Create the file $dir->createFile(YDPath::getFileName($path), $xml); }
/** * Function to get the full path of the object. * * @returns String containing the full path of the object. */ function getPath() { return YDPath::getDirectoryName($this->getAbsolutePath()); }
/** * This function deletes a file or an array of files from the * target directory. * * @param $files The file name or an array of filenames * relative to the target directory. * * @returns An array with the results. */ function deleteFile($files) { if (!is_array($files)) { $files = array($files); } $res = array(); foreach ($files as $file) { // The file path $file = YDPath::join($this->_target_dir, $file); if (!is_file($file)) { $res[] = array('success' => false, 'action' => 'delete', 'type' => 'file', 'item' => $file, 'reason' => 'exist'); if ($this->_log) { YDLog::warning('Deleting file: ' . $file . ' - already exist'); } continue; } // Target directory path $dir = YDPath::getDirectoryName($file); // The directory $d = new YDFSDirectory($dir); // Delete the file if (!($success = $d->deleteFile($file))) { if ($this->_log) { YDLog::error('Deleting file: ' . $file); } } else { if ($this->_log) { YDLog::info('Deleting file: ' . $file); } } $res[] = array('success' => $success, 'action' => 'delete', 'type' => 'file', 'item' => $file, 'reason' => 'failure'); } return $res; }