本文整理汇总了C++中FilePath::getPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::getPath方法的具体用法?C++ FilePath::getPath怎么用?C++ FilePath::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath::getPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exe
bool CommandRm::exe(tfs::api::FileSystem& fs, string parameter)
{
FilePath pathGenerator;
istringstream input(parameter);
string path;
string commandType;
input >> commandType >>path;
/**
* if there is only one parameter,it should be the filepath
* which will be removed later, or romove the directory
*/
if(path == ""){
path = commandType;
path = pathGenerator.getPath(m_currentDir, path);
path = pathGenerator.change(path);
return removeFile(fs, path);
}
else if(commandType == "-rf"){
path = pathGenerator.getPath(m_currentDir, path);
path = pathGenerator.change(path);
return removeDirectory(fs, path);
}
cout << "<USAGE> rm <filepath>" << endl;
cout << "<USAGE> rm -rf <filepath>" << endl;
return false;
}
示例2: testGetPath
void testGetPath()
{
std::string c0("test/");
std::string c1("/dir/test2/");
std::string result = m_path.getPath(c1,c0);
TS_ASSERT_EQUALS(result, "/dir/test2/test/");
result = m_path.getPath(c1,c1);
TS_ASSERT_EQUALS(result, "/dir/test2/");
}
示例3: if
std::pair<PExprNode, FilePath> FileCompiler::loadCode(ExprLocation loc, ConstStrA name)
{
FilePath p = loc.getFileName();
if (p.getPath().empty()) p = FilePath(ConstStrW(L"."), true);
for (ConstStrA::SplitIterator iter = name.split('/'); iter.hasItems();) {
ConstStrA part = iter.getNext();
if (part.empty()) {
continue;
}
else if (part == "..") {
p = p / parent;
}
else {
p = p / part;
}
}
const PExprNode *code = codeCache.find(p);
PExprNode out;
if (code) out = *code;
else {
out = compileFile(p);
codeCache(p, out);
}
return std::make_pair(out, p);
}
示例4: in
vector<Highscores::Score> Highscores::fromFile(const FilePath& path) {
vector<Highscores::Score> scores;
try {
CompressedInput in(path.getPath());
in.getArchive() >> scores;
} catch (...) {}
return scores.filter([](const Score& s) { return s.version == highscoreVersion;});
}
示例5: CHECK
SoundBuffer::SoundBuffer(const FilePath& path) {
OggVorbis_File file;
CHECK(ov_fopen(path.getPath(), &file) == 0) << "Error opening audio file: " << path;
vorbis_info* info = ov_info(&file, -1);
ov_raw_seek(&file, 0);
vector<char> buffer = readSoundData(file);
OpenalId id;
AL(alGenBuffers(1, &id));
AL(alBufferData(id, (info->channels > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, buffer.data(), buffer.size(),
info->rate));
bufferId = id;
ov_clear(&file);
}
示例6: exe
bool CommandPut::exe(FileSystem& fs, string parameter)
{
istringstream input(parameter);
string tfsPath;
string localPath;
int blocksize = -1; // add by fk
input >> localPath >> tfsPath >>blocksize; //get the parameters
if (blocksize == -1) blocksize = 1;
/**
* if the path is null, it puts nothing
*/
if(tfsPath == "" && localPath == ""){
cout << "USAGE: put <local_file> [<tfs_file>]" << endl;
cout << "EXAMPLE: put filename1" << endl;
cout << " put filename1 ." << endl;
cout << " put filename1 ./filename2" << endl;
cout << " put /home/abc/filename1" << endl;
cout << " put /home/abc/filename1 ./filename2" << endl;
return false;
}
// check local file
struct stat fileStat;
if (stat(localPath.c_str(), &fileStat) != 0){
cout << "Error: put: no such file " << localPath << endl;
return false;
}
bool bAbsolutePath;
string localDir;
string localFilename;
FilePath::split(localPath, bAbsolutePath, localDir, localFilename);
string tfsDir;
string tfsFilename;
FilePath::split(tfsPath, bAbsolutePath, tfsDir, tfsFilename);
if (!bAbsolutePath){ // reletive path
FilePath pathGenerator;
tfsDir = pathGenerator.getPath(m_currentDir, tfsDir);
tfsDir = pathGenerator.change(tfsDir); //change into absolutely path
if(tfsDir != "/"){
tfsDir += "/";
}
}
if (tfsFilename.empty()){
tfsFilename = localFilename;
}
tfsPath = tfsDir + tfsFilename;
cout << "put " << localPath << " " << tfsPath << endl;
try{
if( !fs.existDirectory(tfsDir) ){
cout << "Error: no such directory " << tfsDir << endl;
return false;
}
//if the file is exist , the local file will be appended
if( !fs.existFile(tfsPath) ){
int chunkSize = (fileStat.st_size > MAX_CHUNK_SIZE) ? MAX_CHUNK_SIZE:DEFAULT_CHUNK_SIZE;
chunkSize = chunkSize - chunkSize % blocksize;
fs.createFile(tfsPath, 2 , chunkSize);
}
AppendStream tfsAppend;
int bufferSize = (fileStat.st_size < MAX_BUFFER_SIZE) ? MAX_BUFFER_SIZE:DEFAULT_BUFFER_SIZE;
tfsAppend.open(tfsPath, bufferSize);
ifstream fin(localPath.c_str() , ios::binary);
if(!fin){
cout << "ERROR: put: open file " << localPath << endl;
return false;
}
size_t MAXGET = 1024 * 1024 / blocksize * blocksize;
if (MAXGET == 0) throw (TFSException("Block Size Exceed 1 M"));
char *buffer = new char[MAXGET];
while(fin){
fin.read(buffer, MAXGET);
//cout << "read " << fin.gcount() << endl;
tfsAppend.append(buffer, fin.gcount());
}
}
catch(TFSException& ex){
cout << "ERROR: put: Get exception: " << ex.what() << endl;
return false;
}
return true;
}
示例7: main
int main (int argc, char **argv) {
#ifdef USE_SSI_LEAK_DETECTOR
{
#endif
char info[1024];
ssi_sprint (info, "\n%s\n\nbuild version: %s\n\n", SSI_COPYRIGHT, SSI_VERSION);
//**** READ COMMAND LINE ****//
CmdArgParser cmd;
cmd.info (info);
ssi_char_t *dllpath = 0;
ssi_char_t *apipath = 0;
ssi_char_t *outdir = 0;
ssi_char_t *reg = 0;
bool index;
cmd.addText("\nArguments:");
cmd.addSCmdArg("dllpath", &dllpath, "input path to dll");
cmd.addText ("\nOptions:");
cmd.addSCmdOption ("-dir", &outdir, "", "output directory []");
cmd.addBCmdOption ("-index", &index, false, "create index [false]");
cmd.addSCmdOption ("-reg", ®, "", "register additional dll's (if several separate by semicolon)");
if (cmd.read (argc, argv)) {
ssi_char_t string[SSI_MAX_CHAR];
FilePath fp (dllpath);
ssi_char_t *dllpath_with_ext = 0;
if (strcmp (fp.getExtension (), ".dll") != 0) {
dllpath_with_ext = ssi_strcat (dllpath, ".dll");
} else {
dllpath_with_ext = ssi_strcpy (dllpath);
}
if (Factory::RegisterDLL (dllpath_with_ext)) {
// register additional dlls
if (reg) {
APIGenerator::SaveCurrentComponentList ();
ssi_size_t n_reg = ssi_split_string_count (reg, ';');
ssi_char_t **regs = new ssi_char_t *[n_reg];
ssi_split_string (n_reg, regs, reg, ';');
for (ssi_size_t i = 0; i < n_reg; i++) {
Factory::RegisterDLL (regs[i]);
delete[] regs[i];
}
delete[] regs;
}
if (outdir[0] == '\0') {
ssi_sprint (string, "%s", fp.getPath ());
} else {
ssi_sprint (string, "%s\\%s", outdir, fp.getName ());
}
APIGenerator::CreateAPI (string);
APIGenerator::ResetCurrentComponentList ();
Factory::Clear ();
}
if (index) {
if (outdir[0] == '\0') {
APIGenerator::CreateAPIIndex (fp.getDir ());
} else {
APIGenerator::CreateAPIIndex (outdir);
}
}
delete[] dllpath_with_ext;
}
delete[] dllpath;
delete[] apipath;
delete[] outdir;
#ifdef USE_SSI_LEAK_DETECTOR
}
_CrtDumpMemoryLeaks();
#endif
return 0;
}
示例8: init
void SoundStream::init(const FilePath& path) {
CHECK(ov_fopen(path.getPath(), file.get()) == 0) << "Error opening audio file: " << path;
info = ov_info(file.get(), -1);
AL(alGenBuffers(2, buffers));
}
示例9: saveToFile
void Highscores::saveToFile(const vector<Score>& scores, const FilePath& path) {
CompressedOutput out(path.getPath());
out.getArchive() << scores;
}
示例10: main
int main(int argc, char *argv[])
{
FilePath path;
printf("%s/n", path.getPath());
return 0;
}