00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "LampBasic.h"
00026 #include "Core/InputOutput/FilePath.h"
00027
00028 namespace Lamp{
00029
00030
00031
00032 String FilePath::getName() const{
00033 String fileName = getFileName();
00034 int lastDotIndex = fileName.getLastIndexOf('.');
00035 if(lastDotIndex != -1){
00036 fileName = fileName.getSubstring(0, lastDotIndex);
00037 }
00038 return fileName;
00039 }
00040
00041
00042 String FilePath::getFileName() const{
00043 int dirIndex = path_.getLastIndexOf("/");
00044 int enIndex = path_.getLastIndexOf("\\");
00045 if(dirIndex < enIndex){ dirIndex = enIndex; }
00046 String fileName = path_;
00047 if(dirIndex != -1){
00048 fileName = path_.getSubstring(dirIndex + 1);
00049 }
00050 return fileName;
00051 }
00052
00053
00054 String FilePath::getExtension() const{
00055 String extension;
00056 int lastDotIndex = path_.getLastIndexOf('.');
00057 if(lastDotIndex != -1){
00058 extension = path_.getSubstring(lastDotIndex + 1);
00059 }
00060 return extension.getLowerCase();
00061 }
00062
00063
00064 String FilePath::getFolderPath() const{
00065 String folderPath;
00066 int dirIndex = path_.getLastIndexOf("/");
00067 int enIndex = path_.getLastIndexOf("\\");
00068 if(dirIndex < enIndex){ dirIndex = enIndex; }
00069 if(dirIndex != -1){
00070 folderPath = path_.getSubstring(0, dirIndex + 1);
00071 }
00072 return folderPath;
00073 }
00074
00075
00076 bool FilePath::existFile() const{
00077 FILE* file = fopen(path_.getBytes(), "rb");
00078 if(file == NULL){ return false; }
00079 fclose(file);
00080 return true;
00081 }
00082
00083 }
00084