| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | class FileIO { |
| 8: | public static function fileExists($filePath){ |
| 9: | $ret = false; |
| 10: | if(file_exists($filePath) && !is_dir($filePath)){ |
| 11: | $ret = true; |
| 12: | } |
| 13: | return $ret; |
| 14: | } |
| 15: | public static function fileCreate($filePath){ |
| 16: | $FileHandle = fopen($filePath, 'w') or die("can't create file $filePath"); |
| 17: | fclose($FileHandle); |
| 18: | } |
| 19: | public static function fileCopy($src,$dst,$overwrite=false){ |
| 20: | $ret = false; |
| 21: | if($overwrite){ |
| 22: | $cop = copy($src,$dst); |
| 23: | }else{ |
| 24: | if(!file_exists($src)){ |
| 25: | $cop = copy($src,$dst); |
| 26: | }else{ |
| 27: | error_log("$src File Already Exists", 0); |
| 28: | } |
| 29: | } |
| 30: | if($cop){ |
| 31: | $ret = true; |
| 32: | } |
| 33: | return $ret; |
| 34: | } |
| 35: | public static function fileWrite($fileURL,$data){ |
| 36: | $ret = false; |
| 37: | if(file_put_contents($fileURL, $data)){ |
| 38: | $ret = true; |
| 39: | } |
| 40: | return $ret; |
| 41: | } |
| 42: | public static function fileAppend($fileURL,$data){ |
| 43: | $ret = false; |
| 44: | if(file_put_contents($fileURL, $data, FILE_APPEND)){ |
| 45: | $ret = true; |
| 46: | } |
| 47: | return $ret; |
| 48: | } |
| 49: | public static function fileRead($fileURL){ |
| 50: | $strOut = file_get_contents($fileURL); |
| 51: | return $strOut; |
| 52: | } |
| 53: | public static function getFileExtentionName($fileURL){ |
| 54: | $rt = strripos($fileURL,'.'); |
| 55: | $ext = substr($fileURL,$rt+1,strlen($fileURL)-$rt-1); |
| 56: | return $ext; |
| 57: | } |
| 58: | public static function getFileName($fileURL){ |
| 59: | $file = basename($fileURL); return $file; |
| 60: | } |
| 61: | public function isFileExpired($filename,$ttl=0){} |
| 62: | public function openFileBytes($filepath){} |
| 63: | } |
| 64: | ?> |