本文整理汇总了C++中file类的典型用法代码示例。如果您正苦于以下问题:C++ file类的具体用法?C++ file怎么用?C++ file使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了file类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
}
示例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;
}
}
}
示例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);
}
示例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());
}
}
}
示例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);
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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()) + ")");
}
}
示例11: addfile
bool fileList::addfile(file& newFile)
{
fileList::entry e;
e.setpath(newFile.getpath());
filelst.push_back(e);
return true;
}
示例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.");
}
}
示例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;
}
示例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
}
}
示例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.");
}