Static Public Member Functions | |
| static | getRelativePath ($strFileFrom, $strFileTo, $booValidPath=true) |
| static | isRelativePath ($strFile) |
| static | getPathOfFile ($strFile) |
Definition at line 12 of file CorujaFileManipulation.class.php.
| static getPathOfFile | ( | $ | strFile | ) | [static] |
Get the path of the file
| string | $strFile |
Definition at line 140 of file CorujaFileManipulation.class.php.
References $strFile.
Referenced by CodeToDiagram::checkPermissionToWrite(), Loader::requireOnce(), and CodeToDiagram::setCallerPathByFile().
00141 { 00142 return str_replace( "\\" , "/" , str_replace( basename( $strFile ) , "" , $strFile ) ); 00143 }
| static getRelativePath | ( | $ | strFileFrom, | |
| $ | strFileTo, | |||
| $ | booValidPath = true | |||
| ) | [static] |
Returns a path to a folder relative from another folder. Both parameters must be absolute.
| String | $strFileFrom Base from the path. This must be an absolute path. | |
| String | $strFileTo Destination of the path. This must be an absolute path. | |
| Boolean | $booValidPath Use false if you don't want to check for valid folders. |
| InvalidArgumentException | In case of invalid values |
\1
true
Definition at line 44 of file CorujaFileManipulation.class.php.
Referenced by UmlSequenceDiagramPrinterConfigurationToXml::getPublicFolderPath(), and UmlSequenceDiagramPrinterConfigurationToHtml::getPublicFolderPath().
00045 { 00046 // check for valid parameters 00047 00048 $strFileFrom = str_replace( "\\" , "/" , $strFileFrom ); 00049 $strFileTo = str_replace( "\\" , "/" , $strFileTo ); 00050 00051 if( $booValidPath 00052 && ( ! is_dir( $strFileFrom ) || ! is_dir( $strFileTo ) ) 00053 ) 00054 { 00055 throw new InvalidArgumentException("Invalid parameter: strFileFrom: ".$strFileFrom." strFileTo: ".$strFileTo); 00056 } 00057 00058 // special case: equal paths 00059 if( $strFileFrom == $strFileTo ) 00060 { 00061 $strReturnPath = './'; 00062 } 00063 else 00064 { 00065 // explode parameters using '/' 00066 $arrFileFrom = explode( '/', $strFileFrom ); 00067 $arrFileTo = explode( '/', $strFileTo ); 00068 00069 // remove similar base folders 00070 while( 00071 current( $arrFileFrom ) == current( $arrFileTo ) 00072 && count( $arrFileFrom ) > 0 00073 ) 00074 { 00075 array_shift( $arrFileFrom ); 00076 array_shift( $arrFileTo ); 00077 } 00078 00079 $arrReturnPath = array(); 00080 00081 // make final address 00082 foreach( $arrFileFrom as $strFolder ) 00083 { 00084 if( $strFolder != "" ) { 00085 $arrReturnPath[] = ".."; 00086 } 00087 } 00088 00089 foreach( $arrFileTo as $strFolder ) 00090 { 00091 $arrReturnPath[] = $strFolder; 00092 } 00093 00094 $strReturnPath = implode( '/', $arrReturnPath ); 00095 } 00096 return $strReturnPath; 00097 }
| static isRelativePath | ( | $ | strFile | ) | [static] |
Check if a address is relative
Definition at line 113 of file CorujaFileManipulation.class.php.
References $strFile.
Referenced by CodeToDiagram::loadFile(), and Loader::requireOnce().
00114 { 00115 $strFile = str_replace( "\\", "/", $strFile); 00116 if( 00117 ( strpos( $strFile, "./") === 0 ) 00118 or 00119 ( strpos( $strFile, "../") === 0 ) 00120 ) 00121 { 00122 return true; 00123 } 00124 elseif( strpos( $strFile, "/") === false ) 00125 { 00126 return true; 00127 } 00128 else 00129 { 00130 return false; 00131 } 00132 }
1.5.9