本文整理汇总了C++中FileMap类的典型用法代码示例。如果您正苦于以下问题:C++ FileMap类的具体用法?C++ FileMap怎么用?C++ FileMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AllItems
//*******************************************************************
// compare_files PRIVATE
//-------------------------------------------------------------------
// Porownanie wszystkich przyslanych plikow.
// Kryterium porownywania jest czas ich ostatniej modyfikacji.
//*******************************************************************
void QBtCompareDirsDialog::compare_files( const FileMap& in_data1, const FileMap& in_data2 )
{
QBtShared::idle();
if( !continue_ ) return;
AllItems data_all = AllItems();
join_files( data_all, in_data1 );
join_files( data_all, in_data2 );
if( data_all.empty() ) return;
RowData row_data;
AllItems::const_iterator it = data_all.begin();
const AllItems::const_iterator end = data_all.end();
while( continue_ && ( it != end ) ) {
const QString name = it.key();
const FileMap::const_iterator it1 = in_data1.find( name );
const FileMap::const_iterator it2 = in_data2.find( name );
const bool is1 = ( it1 != in_data1.end() );
const bool is2 = ( it2 != in_data2.end() );
row_data.reset();
if( is1 ) row_data.set_lft( name, it1.value().absoluteFilePath() );
if( is2 ) row_data.set_rgt( name, it2.value().absoluteFilePath() );
if( is1 && is2 ) {
row_data.separator( check_files( row_data.path1(), row_data.path2() ) );
}
add_row( row_data );
++it;
}
}
示例2: LOGW
FileMap*
FileMapBuffer::createMap(const char* filename)
{
int fd;
size_t length;
fd = ::open(filename, O_RDONLY | O_BINARY);
if (fd < 0) {
LOGW("Unable to open file '%s': %s\n", filename, strerror(errno));
return NULL;
}
length = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
FileMap* map = new FileMap();
if (!map) {
LOGW("Unable to create file map for '%s': %s\n", filename, strerror(errno));
return NULL;
}
if (!map->create(filename, fd, 0, length, true)) {
map->release();
LOGW("Unable to create file map for '%s': %s\n", filename, strerror(errno));
return NULL;
}
close(fd);
return map;
}
示例3: unmap
void Memory::unmap(hostptr_t addr, size_t /*count*/)
{
FileMapEntry entry = Files.find(addr);
if(Files.remove(addr) == false) return;
UnmapViewOfFile(entry.address());
CloseHandle(entry.handle());
}
示例4: fssh_file_map_set_size
extern "C" void
fssh_file_map_set_size(void* _map, fssh_off_t size)
{
FileMap* map = (FileMap*)_map;
if (map == NULL)
return;
map->SetSize(size);
}
示例5: fssh_file_map_set_mode
extern "C" fssh_status_t
fssh_file_map_set_mode(void* _map, uint32_t mode)
{
FileMap* map = (FileMap*)_map;
if (map == NULL)
return FSSH_B_BAD_VALUE;
return map->SetMode(mode);
}
示例6: fssh_file_map_invalidate
extern "C" void
fssh_file_map_invalidate(void* _map, fssh_off_t offset, fssh_off_t size)
{
FileMap* map = (FileMap*)_map;
if (map == NULL)
return;
map->Invalidate(offset, size);
}
示例7: release
// Call instead of delete:
void DataFile::release ()
{
if (--_ref_count <= 0)
{
FileMap::iterator i = open_data_files.find (_filename);
LOG_ASSERT (i != open_data_files.end ());
open_data_files.erase (i);
delete this;
}
}
示例8: join_files
//*******************************************************************
// join_files PRIVATE
//*******************************************************************
void QBtCompareDirsDialog::join_files( AllItems& out_set, const FileMap& in_map ) const
{
if( in_map.empty() ) return;
FileMap::const_iterator it = in_map.begin();
const FileMap::const_iterator end = in_map.end();
while( continue_ && ( it != end ) ) {
out_set.insert( it.key(), QString() );
++it;
}
}
示例9: fssh_file_map_translate
extern "C" fssh_status_t
fssh_file_map_translate(void* _map, fssh_off_t offset, fssh_size_t size,
fssh_file_io_vec* vecs, fssh_size_t* _count, fssh_size_t align)
{
TRACE(("file_map_translate(map %p, offset %Ld, size %ld)\n",
_map, offset, size));
FileMap* map = (FileMap*)_map;
if (map == NULL)
return FSSH_B_BAD_VALUE;
return map->Translate(offset, size, vecs, _count, align);
}
示例10: ALOGE
status_t Tokenizer::open(const String8& filename, Tokenizer** outTokenizer) {
*outTokenizer = NULL;
int result = NO_ERROR;
int fd = ::open(filename.string(), O_RDONLY);
if (fd < 0) {
result = -errno;
ALOGE("Error opening file '%s', %s.", filename.string(), strerror(errno));
} else {
struct stat stat;
if (fstat(fd, &stat)) {
result = -errno;
ALOGE("Error getting size of file '%s', %s.", filename.string(), strerror(errno));
} else {
size_t length = size_t(stat.st_size);
FileMap* fileMap = new FileMap();
bool ownBuffer = false;
char* buffer;
if (fileMap->create(NULL, fd, 0, length, true)) {
fileMap->advise(FileMap::SEQUENTIAL);
buffer = static_cast<char*>(fileMap->getDataPtr());
} else {
delete fileMap;
fileMap = NULL;
// Fall back to reading into a buffer since we can't mmap files in sysfs.
// The length we obtained from stat is wrong too (it will always be 4096)
// so we must trust that read will read the entire file.
buffer = new char[length];
ownBuffer = true;
ssize_t nrd = read(fd, buffer, length);
if (nrd < 0) {
result = -errno;
ALOGE("Error reading file '%s', %s.", filename.string(), strerror(errno));
delete[] buffer;
buffer = NULL;
} else {
length = size_t(nrd);
}
}
if (!result) {
*outTokenizer = new Tokenizer(filename, fileMap, buffer, ownBuffer, length);
}
}
close(fd);
}
return result;
}
示例11: CHECK
void daemon_pipe::exec()
{
CHECK(!m_specs.empty(), "no procs to execute");
SignalBlocker signals;
// LockFile will be unlocked on destruction; don't do this until
// after the ProcHarvester is destroyed
LockFile lock;
// ProcHarvester will wait for all children on destruction. Since we want
// all the FDs to get closed before that happens, this must be instantiated
// before the FileMap.
ProcHarvester harvester(&signals.m_sigset);
// build a map of all the files we're going to need to open, and whether
// we need to read or write from them
FileMap files;
for(std::vector<daemon_proc_spec_ptr>::iterator i = m_specs.begin(), end = m_specs.end(); i != end; ++i)
{
Proc &proc(harvester.addProc(*i));
if((*i)->m_stdin)
proc.m_stdin = files.get((*i)->m_stdin, true, false);
if((*i)->m_stdout)
proc.m_stdout = files.get((*i)->m_stdout, false, true);
if((*i)->m_stderr)
proc.m_stderr = files.get((*i)->m_stderr, false, true);
}
if(!m_lockFile.empty())
lock.open(m_lockFile);
std::vector<File *>::const_iterator file = files.m_files.begin(),
end = files.m_files.end();
for(; file != end; ++file)
(*file)->open();
int pgid = 0;
for(std::vector<ProcPtr>::iterator i = harvester.m_procs.begin(), end = harvester.m_procs.end(); i != end; ++i)
{
Proc &proc = **i;
proc.m_blockedSignals = &signals;
proc.m_newPGID = pgid;
int pid = proc.safe_fork_exec();
if(pgid == 0)
pgid = pid;
}
}
示例12: main
int main()
{
int fd;
FileMap *pFile = FileMap::getInstance();
for(;;)
{
fd = pFile->getFileFd("rr");
if(fd<0)
cout<<"fd:"<<strerror(errno)<<endl;
else cout<<"fd:"<<fd<<endl;
}
pFile->traverse();
pFile->close(fd);
return 0;
}
示例13: Create
File* File::Create(const CString& filename)
{
// Check the map.
File* file = g_globalFileMap.Get(filename);
if (file)
return file;
// Create a new file.
file = WNEW File;
File::Create(*file, filename);
// Add to map.
g_globalFileMap.Add(file);
return file;
}
示例14: getFileProperties
bool AdvancedMetaEngine::getFileProperties(const Common::FSNode &parent, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, ADFileProperties &fileProps) const {
// FIXME/TODO: We don't handle the case that a file is listed as a regular
// file and as one with resource fork.
if (game.flags & ADGF_MACRESFORK) {
Common::MacResManager macResMan;
if (!macResMan.open(parent, fname))
return false;
fileProps.md5 = macResMan.computeResForkMD5AsString(_md5Bytes);
fileProps.size = macResMan.getResForkDataSize();
if (fileProps.size != 0)
return true;
}
if (!allFiles.contains(fname))
return false;
Common::File testFile;
if (!testFile.open(allFiles[fname]))
return false;
fileProps.size = (int32)testFile.size();
fileProps.md5 = Common::computeStreamMD5AsString(testFile, _md5Bytes);
return true;
}
示例15: _dyld_find_unwind_sections
bool _dyld_find_unwind_sections(void* addr, struct dyld_unwind_sections* info)
{
TRACE1(addr);
const FileMap::ImageMap* map = g_file_map.imageMapForAddr(addr);
if (!map) // in ELF
{
memset(info, 0, sizeof(*info));
CBData data = { addr, info };
dl_iterate_phdr(dlCallback, &data);
std::cout << "Dwarf section at " << info->dwarf_section << std::endl;
return info->dwarf_section != 0;
}
else // in Mach-O
{
info->mh = &map->header;
info->dwarf_section = reinterpret_cast<const void*>(map->eh_frame.first + map->slide);
info->dwarf_section_length = map->eh_frame.second;
// FIXME: we would get "malformed __unwind_info" warnings otherwise
// info->compact_unwind_section = reinterpret_cast<const void*>(map->unwind_info.first + map->slide);
// info->compact_unwind_section_length = map->unwind_info.second;
info->compact_unwind_section = 0;
info->compact_unwind_section_length = 0;
return true;
}
}