toolsfiles.h
来自「C++ image processing.Mainly it occupies 」· C头文件 代码 · 共 63 行
H
63 行
/*
This "SOFTWARE" is a free software.
You are allowed to download, use, modify and redistribute this software.
The software is provided "AS IS" without warranty of any kind.
Copyright: University of Koblenz-Landau, Dirk Balthasar
*/
/**
\author Dirk Balthasar, 2002, private
*/
#include <stdio.h>
/**
This file specifies operations for handling filenames
@ingroup file-tools
*/
namespace tools
{
/// remove extension of file: "File.***" -> "File"
inline std::string CutExtension(const char *Fname)
{
int FileNameEnd = strlen(Fname);
while (FileNameEnd > 0)
{ // find position where programname starts in "path\program.extension"
char c = Fname[FileNameEnd];
if (c == '.') break;
FileNameEnd--;
}
FileNameEnd--;
if (FileNameEnd >= 0)
{
char * Rvalue = new char[FileNameEnd+2];
Rvalue[FileNameEnd+1] = '\0';
memcpy(Rvalue, Fname, FileNameEnd+1);
std::string r = Rvalue;
delete Rvalue;
return r;
}else
return "";
}
/// returns true if file exists
inline bool FileExists(const char *FileExists)
{
if (strlen(FileExists) == 0)
{
// handle some windows bugs
return false;
}
FILE *fh = fopen(FileExists,"rb");
if (fh == 0)
return false;
fclose(fh);
return true;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?