本文整理汇总了C++中file类的典型用法代码示例。如果您正苦于以下问题:C++ file类的具体用法?C++ file怎么用?C++ file使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了file类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: check_reserved_names
void check_reserved_names(file const& f)
{
// Remove this exception once this file has been reworked.
if(f.phyloanalyze("^ledger_xml_io.cpp$"))
{
return;
}
if(f.is_of_phylum(e_log))
{
return;
}
static boost::regex const r("(\\b\\w*__\\w*\\b)");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
std::string const s = z[0];
static boost::regex const not_all_underscore("[A-Za-z0-9]");
if
( !check_reserved_name_exception(s)
&& boost::regex_search(s, not_all_underscore)
)
{
std::ostringstream oss;
oss << "contains reserved name '" << s << "'.";
complain(f, oss.str());
}
}
}
开发者ID:vadz,项目名称:lmi,代码行数:32,代码来源:test_coding_rules.cpp
示例2: luaStore_writeStrings
void luaStore_writeStrings(stringtable * strt, file&f)
{
GCObject * list;
int i;
// The total amount of strings
f.write(strt->nuse);
for(i = 0;i < strt->size;i++)
{
list = strt->hash[i];
while(list)
{
// write the object pointer
f.write(&list, sizeof(void*));
// write the string length
if(list->ts.tsv.len > 0xFFFF)
dbgError("string too long");
f.write((ushort)list->ts.tsv.len);
// write the string
f.write(&list->ts + 1, list->ts.tsv.len);
// next!
list = list->gch.next;
}
}
}
开发者ID:nateleroux,项目名称:nyEngine,代码行数:29,代码来源:luaStore.cpp
示例3: resolvexdgfolder
//==============================================================================
static file resolvexdgfolder (const char* const type, const char* const fallbackfolder)
{
file userdirs ("~/.config/user-dirs.dirs");
stringarray conflines;
if (userdirs.existsasfile())
{
fileinputstream in (userdirs);
if (in.openedok())
conflines.addlines (in.readentirestreamasstring());
}
for (int i = 0; i < conflines.size(); ++i)
{
const string line (conflines[i].trimstart());
if (line.startswith (type))
{
// eg. resolve xdg_music_dir="$home/music" to /home/user/music
const file f (line.replace ("$home", file ("~").getfullpathname())
.fromfirstoccurrenceof ("=", false, false)
.trim().unquoted());
if (f.isdirectory())
return f;
}
}
return file (fallbackfolder);
}
开发者ID:moorecoin,项目名称:MooreCoinService,代码行数:32,代码来源:bsd_Files.cpp
示例4: check_label_indentation
void check_label_indentation(file const& f)
{
if(!f.is_of_phylum(e_c_or_cxx))
{
return;
}
static boost::regex const r("\\n( *)([A-Za-z][A-Za-z0-9_]*)( *:)(?!:)");
boost::sregex_iterator i(f.data().begin(), f.data().end(), r);
boost::sregex_iterator const omega;
for(; i != omega; ++i)
{
boost::smatch const& z(*i);
if
( "default" != z[2]
&& " " != z[1]
&& " " != z[1]
)
{
std::ostringstream oss;
oss << "has misindented label '" << z[1] << z[2] << z[3] << "'.";
complain(f, oss.str());
}
}
}
开发者ID:vadz,项目名称:lmi,代码行数:25,代码来源:test_coding_rules.cpp
示例5: luaStore_writeLongString
void luaStore_writeLongString(GCObject * obj, file& f)
{
// Long String format:
// ushort length
// length bytes
if(obj->ts.tsv.len > 0xFFFF)
dbgError("string too long");
f.write((ushort)obj->ts.tsv.len);
f.write(&obj->ts + 1, obj->ts.tsv.len);
}
开发者ID:nateleroux,项目名称:nyEngine,代码行数:11,代码来源:luaStore.cpp
示例6: updatefile
bool fileList::updatefile(file& oldFile, file& updFile)
{
for(list<fileList::entry>::iterator it=filelst.begin();
it!=filelst.end(); ++it)
{
if(it->getpath()==oldFile.getpath())
{
it->setpath(updFile.getpath());
return true;
}
}
return false;
}
开发者ID:zsteve,项目名称:bot-source-archiver,代码行数:13,代码来源:filelist.cpp
示例7: get_parent_directory
directory get_parent_directory (
const file& f
)
{
if (f.full_name().size() == 0)
return directory();
std::string::size_type pos = f.full_name().find_last_of("\\/");
if (pos == std::string::npos)
return directory();
return directory(f.full_name().substr(0,pos));
}
开发者ID:23119841,项目名称:FERA-2015,代码行数:14,代码来源:dir_nav_extensions.cpp
示例8: checkfile
bool fileList::checkfile(file& chkFile)
{
fileList::entry e;
e.setpath(chkFile.getpath());
for(list<fileList::entry>::iterator it=filelst.begin();
it!=filelst.end(); ++it)
{
if(it->getpath()==chkFile.getpath())
{
return true;
}
}
return false;
}
开发者ID:zsteve,项目名称:bot-source-archiver,代码行数:14,代码来源:filelist.cpp
示例9: getDirSize
static file::size_type getDirSize(const file& d) {
file::size_type res = 0;
string path = d.path();
vector<struct dirent> files = d.list_files((flags & F_ALL) != 0);
for(auto it = files.begin(); it != files.end(); ++it) {
file f(path,it->d_name);
if(f.is_dir()) {
string name = f.name();
if(name != "." && name != "..")
res += getDirSize(f);
}
else
res += f.size();
}
return res;
}
开发者ID:Logout22,项目名称:Escape,代码行数:16,代码来源:ls.cpp
示例10: source_
position::position(const file& source, size_t line, size_t col, size_t index) : source_(&source), line_(line), col_(col), index_(index) {
assert(line >= 1);
assert(col >= 1);
if (index > source.length()) {
throw std::logic_error("position (" + std::to_string(index) + ") is out of range (" + std::to_string(source.length()) + ")");
}
}
开发者ID:mras0,项目名称:solve,代码行数:7,代码来源:source.cpp
示例11: addfile
bool fileList::addfile(file& newFile)
{
fileList::entry e;
e.setpath(newFile.getpath());
filelst.push_back(e);
return true;
}
开发者ID:zsteve,项目名称:bot-source-archiver,代码行数:7,代码来源:filelist.cpp
示例12: assay_non_latin
void assay_non_latin(file const& f)
{
static boost::regex const forbidden("[\\x00-\\x08\\x0e-\\x1f\\x7f-\\x9f]");
if(boost::regex_search(f.data(), forbidden))
{
throw std::runtime_error("File contains a forbidden character.");
}
}
开发者ID:vadz,项目名称:lmi,代码行数:8,代码来源:test_coding_rules.cpp
示例13: size
bool file::operator==( const file &other ) const
{
if( sorting == by_size )
return size() == other.size();
if( sorting == by_date )
return date() == other.date();
if( sorting == by_extension )
return ext() == other.ext();
if( sorting == by_type )
return is_dir() == other.is_dir();
//if( sorting == by_name )
return pathfile == other.pathfile;
}
开发者ID:shammellee,项目名称:moon9,代码行数:17,代码来源:file.cpp
示例14:
void fs::file_ptr::reset(const file& f)
{
reset();
if (f)
{
#ifdef _WIN32
const HANDLE handle = ::CreateFileMapping((HANDLE)f.m_fd, NULL, PAGE_READONLY, 0, 0, NULL);
m_ptr = (char*)::MapViewOfFile(handle, FILE_MAP_READ, 0, 0, 0);
m_size = f.size();
::CloseHandle(handle);
#else
m_ptr = (char*)::mmap(nullptr, m_size = f.size(), PROT_READ, MAP_SHARED, f.m_fd, 0);
if (m_ptr == (void*)-1) m_ptr = nullptr;
#endif
}
}
开发者ID:ss23,项目名称:rpcs3,代码行数:17,代码来源:File.cpp
示例15: check_preamble
void check_preamble(file const& f)
{
if
( f.is_of_phylum(e_gpl)
|| f.is_of_phylum(e_md5)
|| f.is_of_phylum(e_patch)
|| f.is_of_phylum(e_rates)
|| f.is_of_phylum(e_touchstone)
|| f.is_of_phylum(e_xml_input)
)
{
return;
}
static std::string const url("http://savannah.nongnu.org/projects/lmi");
require(f, url, "lacks lmi URL.");
}
开发者ID:vadz,项目名称:lmi,代码行数:17,代码来源:test_coding_rules.cpp
示例16: OnStopCapture
//This function is called when a capture is stopped
//"block" holds an object representing the current script block on the flowchart
void OnStopCapture(ScriptBlock block)
{
if (bFileOpen == true) {
handle.close();
}
//block.ClearOutputText(); //Clear this scripts output window
block.PrintOutputText("Binary file write stopped\n", false, false, false, false); //Print to the output window
}
开发者ID:cancapture,项目名称:CANCapture-Resources,代码行数:11,代码来源:binary-file-read-and-transmit.c
示例17: check_config_hpp
void check_config_hpp(file const& f)
{
static std::string const loose ("# *include *[<\"]config.hpp[>\"]");
static std::string const strict ("\\n(#include \"config.hpp\")\\n");
static std::string const indent ("\\n(# include \"config.hpp\")\\n");
if
( f.is_of_phylum(e_log)
|| f.phyloanalyze("^test_coding_rules_test.sh$")
|| f.phyloanalyze("^GNUmakefile$")
|| f.phyloanalyze("^pchfile(_.*)?\\.hpp$")
)
{
return;
}
else if(f.is_of_phylum(e_header) && f.phyloanalyze("^pchlist(_.*)?\\.hpp$"))
{
require(f, loose , "must include 'config.hpp'.");
require(f, indent, "lacks line '# include \"config.hpp\"'.");
boost::smatch match;
static boost::regex const first_include("(# *include[^\\n]*)");
boost::regex_search(f.data(), match, first_include);
if("# include \"config.hpp\"" != match[1])
{
complain(f, "must include 'config.hpp' first.");
}
}
else if(f.is_of_phylum(e_header) && !f.phyloanalyze("^config(_.*)?\\.hpp$"))
{
require(f, loose , "must include 'config.hpp'.");
require(f, strict, "lacks line '#include \"config.hpp\"'.");
boost::smatch match;
static boost::regex const first_include("(# *include[^\\n]*)");
boost::regex_search(f.data(), match, first_include);
if("#include \"config.hpp\"" != match[1])
{
complain(f, "must include 'config.hpp' first.");
}
}
else
{
forbid(f, loose, "must not include 'config.hpp'.");
}
}
开发者ID:vadz,项目名称:lmi,代码行数:44,代码来源:test_coding_rules.cpp
示例18: luaStore_writeTable
void luaStore_writeTable(GCObject * obj, file& f, std::vector<void *>& functions)
{
// Table format:
// int sizearray
// sizearray objects
f.write(obj->h.sizearray);
int i;
for(i = 0;i < obj->h.sizearray;i++)
luaStore_writeValue(&obj->h.array[i], f, functions);
}
开发者ID:nateleroux,项目名称:nyEngine,代码行数:11,代码来源:luaStore.cpp
示例19: check_include_guards
void check_include_guards(file const& f)
{
if(!f.is_of_phylum(e_cxx_header))
{
return;
}
std::string const guard = boost::regex_replace
(f.leaf_name()
,boost::regex("\\.hpp$")
,"_hpp"
);
std::string const guards =
"\\n#ifndef " + guard
+ "\\n#define " + guard + "\\n"
+ ".*"
+ "\\n#endif // " + guard + "\\n+$"
;
require(f, guards, "lacks canonical header guards.");
}
开发者ID:vadz,项目名称:lmi,代码行数:20,代码来源:test_coding_rules.cpp
示例20: complain
void forbid
(file const& f
,std::string const& regex
,std::string const& complaint
)
{
if(boost::regex_search(f.data(), boost::regex(regex)))
{
complain(f, complaint);
}
}
开发者ID:vadz,项目名称:lmi,代码行数:11,代码来源:test_coding_rules.cpp
注:本文中的file类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论