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 combines different file path elements to each other. * * @code * join( 'C:\temp', 'subdir', 'file.html' ) * @endcode * * results in the following path: * * @code * C:\temp\subdir\file.html * @endcode * * @returns The joined path. * * @static */ function join() { // Get the arguments for this function $args = func_get_args(); // Start with an empty path $path = ''; // Loop over the different elements foreach ($args as $arg) { if (!strlen($arg)) { continue; } // Normalize the path elements $arg = str_replace('/', YDPath::getDirectorySeparator(), $arg); $arg = str_replace('\\', YDPath::getDirectorySeparator(), $arg); // Check for an absolute path if (YDPath::isAbsolute($arg)) { $path = $arg; } else { // Remove the trailing directory separator if (substr($arg, -1, 1) == YDPath::getDirectorySeparator()) { $arg = substr($arg, 0, -1); } // Add it to the path if (strlen($path) > 0) { if (substr($arg, 0, 1) != YDPath::getDirectorySeparator()) { $path .= YDPath::getDirectorySeparator() . $arg; } else { $path .= $arg; } } else { $path .= $arg; } } } // Return the joined path return $path; }