static int luaFuncResources(lua_State* l) { Block* b = mbGetActiveContext()->ActiveBlock(); if (!b) { MB_LOGERROR("must be within a block"); mbExitError(); } luaL_checktype(l, 1, LUA_TTABLE); int tableLen = luaL_len(l, 1); FilePathVector strings; for (int i = 1; i <= tableLen; ++i) { lua_rawgeti(l, 1, i); strings.push_back(FilePath()); mbLuaToStringExpandMacros(&strings.back(), b, l, -1); } StringVector filteredList; BuildFileList(&filteredList, strings); b->AddResources(filteredList); return 0; }
void TranslationUnit::printResourceUsage(std::ostream& ostr, bool detailed) const { CXTUResourceUsage usage = clang().getCXTUResourceUsage(tu_); unsigned long totalBytes = 0; for (unsigned i = 0; i < usage.numEntries; i++) { CXTUResourceUsageEntry entry = usage.entries[i]; if (detailed) { ostr << clang().getTUResourceUsageName(entry.kind) << ": " << formatBytes(entry.amount) << std::endl; } if (entry.kind >= CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN && entry.kind <= CXTUResourceUsage_MEMORY_IN_BYTES_END) { totalBytes += entry.amount; } } ostr << "TOTAL MEMORY: " << formatBytes(totalBytes) << " (" << FilePath(getSpelling()).filename() << ")" << std::endl; clang().disposeCXTUResourceUsage(usage); }
void RegularFile::Open(OpenMode::Mode mode) { int flags = 0; switch (mode) { case OpenMode::Read: flags = 0; m_FD->Eof = false; break; case OpenMode::Write: flags = O_CREAT|O_WRONLY|O_TRUNC; break; case OpenMode::Append: flags = O_CREAT|O_WRONLY|O_APPEND; break; default: throw Ape::EInvalidArgument("Invalid OpenMode"); break; } m_FD->FD = open(FilePath().Canonical().CStr(), flags); //printf("%s -> %p\n", FilePath().Canonical().CStr(), m_FD->FD); if (m_FD->FD == -1) { ThrowExceptionFor(errno); } m_Mode = mode; }
// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml". // On Windows, uses \ as the separator rather than /. FilePath FilePath::ConcatPaths(const FilePath& directory, const FilePath& relative_path) { if (directory.IsEmpty()) return relative_path; const FilePath dir(directory.RemoveTrailingPathSeparator()); return FilePath(dir.string() + kPathSeparator + relative_path.string()); }
FilePath AddGenCompDialog::getSelectedGenCompFilePath() const noexcept { if (mSelectedGenComp) return mSelectedGenComp->getDirectory(); else return FilePath(); }
FilePath MipMapReplacer::GetDummyTextureFilePath(Texture * texture) { String formatFile; switch (texture->format) { case FORMAT_ATC_RGB: formatFile = "atc.dds"; break; case FORMAT_ATC_RGBA_EXPLICIT_ALPHA: formatFile = "atce.dds"; break; case FORMAT_ATC_RGBA_INTERPOLATED_ALPHA: formatFile = "atci.dds"; break; case FORMAT_DXT1: formatFile = "dxt1.dds"; break; case FORMAT_DXT1A: formatFile = "dxt1a.dds"; break; case FORMAT_DXT1NM: formatFile = "dxt1nm.dds"; break; case FORMAT_DXT3: formatFile = "dxt3.dds"; break; case FORMAT_DXT5: formatFile = "dxt5.dds"; break; case FORMAT_DXT5NM: formatFile = "dxt5nm.dds"; break; case FORMAT_ETC1: formatFile = "etc1.pvr"; break; case FORMAT_PVR2: formatFile = "pvr2.pvr"; break; case FORMAT_PVR4: formatFile = "pvr4.pvr"; break; default: return FilePath(); } return FilePath(DUMMY_TEXTURES_DIR + formatFile); }
// Returns a copy of the FilePath with the case-insensitive extension removed. // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns // FilePath("dir/file"). If a case-insensitive extension is not // found, returns a copy of the original FilePath. FilePath FilePath::RemoveExtension(const char* extension) const { const std::string dot_extension = std::string(".") + extension; if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) { return FilePath(pathname_.substr( 0, pathname_.length() - dot_extension.length())); } return *this; }
EdManipGUIObject::EdManipGUIObject (void) : _starting_location_t1 (0.0F), _starting_location_t2 (0.0F) { _line_material.setBlendEnable(false); _line_material.setDepthEnable(true); _line_material.setCullMode(DT3GL_CULL_NONE); _line_material.setColor(Color(1.0F,1.0F,1.0F,1.0F)); _line_material.setShader(ShaderResource::getShader(FilePath("{editorline.shdr}"))); _red_material.setBlendEnable(false); _red_material.setDepthEnable(true); _red_material.setCullMode(DT3GL_CULL_NONE); _red_material.setColor(Color(1.0F,0.0F,0.0F,1.0F)); _red_material.setShader(ShaderResource::getShader(FilePath("{editorline.shdr}"))); }
void FileDialog::updateButtons() { FilePath file_path = m_dir_path / FilePath(toUTF8Checked(m_edit_box->text())); if(m_mode == FileDialogMode::opening_file) m_ok_button->enable(file_path.isRegularFile()); else if(m_mode == FileDialogMode::saving_file) m_ok_button->enable(!file_path.isDirectory()); }
/** Returns a vector with all selected file paths. @return a vector with all selected file paths. */ std::vector<FilePath> getSelectedFilePaths() const { std::vector<FilePath> result; int count = getSelectedFileCount(); for(int index = 0; index < count; ++index) { result.push_back(FilePath(getSelectedFile(index))); } return result; }
filesystem::FilePath filesystem::FilePath::toValidPath(const std::string& path) { std::string tmp_path = path; std::replace_if(tmp_path.begin(), tmp_path.end(), ValidSeparator(INVALID_PATH_SEPARATOR), PATH_SEPARATOR); if (tmp_path.back() == PATH_SEPARATOR) tmp_path.erase(tmp_path.end()); return FilePath(tmp_path); }
FilePath FilePath::GetFolder()const { WString delimiter = Delimiter; fint pos = _fullPath.FindLast(L'\\'); if (!pos) return FilePath(); return _fullPath.Left(pos); }
FilePath FilePath::folderPath() const { if (pathParts_.empty()) return FilePath(".."); if (pathParts_.size() == 1) return FilePath(""); if (pathParts_.back() == upString) { std::vector<String> partsWithOnlyUps(pathParts_.size() + 1); std::fill_n(partsWithOnlyUps.begin(), pathParts_.size() + 1, upString); return FilePath(partsWithOnlyUps); } std::vector<String> partsExceptLast(pathParts_.size() - 1); partsExceptLast.reserve(pathParts_.size() - 1); std::copy(pathParts_.begin(), std::prev(pathParts_.end()), partsExceptLast.begin()); return FilePath(partsExceptLast); }
bool TextureAsset::Register(const AssetName& name, const Emoji& emoji, const TextureDesc desc, const AssetParameter& parameter) { return Register(name, TextureAssetData(FilePath(), desc, parameter, [=](TextureAssetData& a) { a.texture = Texture(emoji, a.desc); return !!a.texture; }, TextureAssetData::DefaultUpdate, TextureAssetData::DefaultRelease )); }
FilePath XmlDomElement::getDocFilePath() const noexcept { XmlDomDocument* doc = getDocument(true); if (doc) return doc->getFilePath(); else return FilePath(); }
void PathDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { FilePicker *picker = static_cast<FilePicker*>(editor); model->setData(index, QVariant::fromValue(FilePath(picker->value())), Qt::EditRole); }
SourceIndex::FileInfo FileInfo::getFileInfo(ConstStrW fname) { IFileIOServices &svc = IFileIOServices::getIOServices(); PFolderIterator iter = svc.getFileInfo(fname); return FileInfo(FilePath(iter->getFullPath(), false), iter->getModifiedTime()); }
TEST( FilesystemSnapshot, managingEntries ) { Filesystem& fs = TSingleton< Filesystem >::getInstance(); FilesystemSnapshot snapshot( fs ); snapshot.add( FilePath( "/root/assets/b.txt" ), 0, 0 ); snapshot.add( FilePath( "/root/code/c.lua" ), 0, 0 ); snapshot.add( FilePath( "/root/assets/a.txt" ), 0, 0 ); std::string snapshotStr = "(0)root;(1)code;(2)c.lua;(1)assets;(2)b.txt;(2)a.txt;"; CPPUNIT_ASSERT_EQUAL( snapshotStr, snapshot.toString() ); // removing a non-existing entry from a non-existing directory snapshot.remove( FilePath( "/root/gameplay/x.txt" ) ); CPPUNIT_ASSERT_EQUAL( snapshotStr, snapshot.toString() ); // removing a non-existing entry from an existing directory snapshot.remove( FilePath( "/root/code/x.txt" ) ); CPPUNIT_ASSERT_EQUAL( snapshotStr, snapshot.toString() ); // removing an existing entry snapshot.remove( FilePath( "/root/assets/a.txt" ) ); snapshotStr = "(0)root;(1)code;(2)c.lua;(1)assets;(2)b.txt;"; CPPUNIT_ASSERT_EQUAL( snapshotStr, snapshot.toString() ); // removing an existing entry snapshot.remove( FilePath( "/root/assets" ) ); snapshotStr = "(0)root;(1)code;(2)c.lua;"; CPPUNIT_ASSERT_EQUAL( snapshotStr, snapshot.toString() ); }
//! flatten a path and file name for example: "/you/me/../." becomes "/you" FilePath FilePath::flattenFilename( const FilePath& root ) const { std::string directory = addEndSlash().toString(); directory = StringHelper::replace( directory, "\\", "/" ); FilePath dir; FilePath subdir; int lastpos = 0; std::string::size_type pos = 0; bool lastWasRealDir=false; while( ( pos = directory.find( '/', lastpos) ) != std::string::npos ) { subdir = FilePath( directory.substr(lastpos, pos - lastpos + 1) ); if( subdir.toString() == "../" ) { if (lastWasRealDir) { dir = dir.getUpDir(); dir = dir.getUpDir(); lastWasRealDir=( dir.toString().size()!=0); } else { dir = FilePath( dir.toString() + subdir.toString() ); lastWasRealDir=false; } } else if( subdir.toString() == "/") { dir = root; } else if( subdir.toString() != "./" ) { dir = FilePath( dir.toString() + subdir.toString() ); lastWasRealDir=true; } lastpos = pos + 1; } return dir; }
void PropertyList::AddFilepathProperty(const String &propertyName, const String &extensionFilter, bool clearDataEnabled, editableType propEditType) { PropertyCellData *p = new PropertyCellData(PropertyCellData::PROP_VALUE_FILEPATH); p->cellType = PropertyCell::PROP_CELL_FILEPATH; p->SetFilePath(FilePath()); p->SetClearDataEnabled(clearDataEnabled); p->SetExtensionFilter(extensionFilter); AddProperty(p, propertyName, propEditType); }
Renderer::Renderer(BrickModel * parent) : BrickModel(parent) { itemData.append("Test"); itemData.append("LOl"); path = new FilePathNode(this, FilePath(""), "Data path"); print = new Node<bool>(this, true, "Enable/Disable painting"); }
FilePath TextureDescriptor::GetSourceTexturePathname() const { if(pathname.IsEmpty()) { return FilePath(); } return FilePath::CreateWithNewExtension(pathname, GetSourceTextureExtension()); }
String FilePath::GetLastDirectoryName() const { DVASSERT(!IsEmpty() && IsDirectoryPathname()); String path = absolutePathname; path = path.substr(0, path.length() - 1); return FilePath(path).GetFilename(); }
FileLocation SourceLocation::getSpellingLocation() const { std::string file; unsigned line, column; if (getSpellingLocation(&file, &line, &column)) return FileLocation(FilePath(file), line, column); else return FileLocation(); }
FilePath rBinaryPath() { FilePath binPath = FilePath(R_HomeDir()).complete("bin"); #ifdef _WIN32 return binPath.complete("Rterm.exe"); #else return binPath.complete("R"); #endif }
void GameObjectTestScreen::LoadResources() { manager = GameObjectManager::Create(); bigBox = GameObject::Create(FilePath("~res:/Gfx/GameObjects/blueboxbig")); bigBox->SetPivotPoint(ALIGN_HCENTER | ALIGN_VCENTER); bigBox->SetPosition(200, 200); manager->AddObject(bigBox.Get()); smallBox = GameObject::Create(FilePath("~res:/Gfx/GameObjects/bluebox")); smallBox->SetPivotPoint(ALIGN_HCENTER | ALIGN_VCENTER); bigBox->AddObject(smallBox.Get()); smallCircle = GameObject::Create(FilePath("~res:/Gfx/GameObjects/bluecircle")); smallCircle->SetPosition(bigBox->GetSize()); smallCircle->SetPivotPoint(ALIGN_HCENTER | ALIGN_VCENTER); bigBox->AddObject(smallCircle.Get()); bigBox->SetAngle(DegToRad(30.0f)); time = 0.0f; bigBoxParticles = GameObject::Create(FilePath("~res:/Gfx/GameObjects/blueboxbig")); bigBoxParticles->SetPivotPoint(ALIGN_HCENTER | ALIGN_VCENTER); bigBoxParticles->SetPosition(200, 100); manager->AddObject(bigBoxParticles.Get()); bigBoxEmitter = new ParticleEmitterObject(); bigBoxEmitter->LoadFromYaml(FilePath("~res:/Particles/Sparkles/sparkles_clockmaster_clear.yaml")); bigBoxEmitter->SetPriority(10); // RefPtr<GameObject> centerTest = GameObject::Create("~res:/Gfx/GameObjects/bluecircle"); // centerTest->SetPosition(0, 0); // centerTest->SetPivotPoint(ALIGN_HCENTER | ALIGN_VCENTER); // bigBoxEmitter->AddObject(centerTest.Get()); smallCircle->AddObject(bigBoxEmitter.Get()); #if 0 ParticleEmitterObject* bigBoxEmitterClone = new ParticleEmitterObject(); bigBoxEmitterClone->SetEmitter(bigBoxEmitter->GetEmitter()->Clone()); bigBoxEmitterClone->SetPriority(10); bigBoxEmitterClone->SetPosition(Vector2(300, 300)); manager->AddObject(bigBoxEmitterClone); #endif }
plx::FilePath GetAppDataPath(bool roaming) { auto folder = roaming? FOLDERID_RoamingAppData : FOLDERID_LocalAppData; wchar_t* path = nullptr; auto hr = ::SHGetKnownFolderPath(folder, 0, nullptr, &path); if (hr != S_OK) throw plx::IOException(__LINE__, L"<appdata folder>"); auto fp = FilePath(path); ::CoTaskMemFree(path); return fp; }
bool OSExchangeDataProviderWin::GetFilename(FilePath* path) const { std::vector<string16> filenames; bool success = ClipboardUtil::GetFilenames(source_object_, &filenames); if(success) { *path = FilePath(filenames[0]); } return success; }
// RemoveFileName returns the directory path with the filename removed. // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". // If the FilePath is "a_file" or "/a_file", RemoveFileName returns // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does // not have a file, like "just/a/dir/", it returns the FilePath unmodified. // On Windows platform, '\' is the path separator, otherwise it is '/'. FilePath FilePath::RemoveFileName() const { const char* const last_sep = FindLastPathSeparator(); std::string dir; if (last_sep) { dir = std::string(c_str(), last_sep + 1 - c_str()); } else { dir = kCurrentDirectoryString; } return FilePath(dir); }
/* * Initializes the object, assuming that filename, origin, size, etc are already set on the * member variables. Makes sure the raster can be opened, sets the block size, NODATA value, * pixel size, and the extent of the raster. If not using the full image then makes sure that * the subset chosen (based on origin and size) is valid. If using the full image then sets the * size and origin is assumed to be 0,0 and is set in the constructor. * @param fullImage True if using the full image, False if using a subset. */ void Raster::Init(bool bFullImage) { Init(); GDALDataset * ds = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly); if (ds == NULL) throw RasterManagerException(INPUT_FILE_NOT_VALID, CPLGetLastErrorMsg()); GDALRasterBand * band = ds->GetRasterBand(1); double dRMin, dRMax, dRMean, dRStdDev; // Get some easy stats that GDAL gives us band->GetStatistics( 0 , true, &dRMin, &dRMax, &dRMean, &dRStdDev ); m_dRasterMax = dRMax; m_dRasterMin = dRMin; m_dRasterMean = dRMean; m_dRasterStdDev = dRStdDev; OGRLinearRing ring = OGRLinearRing(); if (bFullImage) { SetCols( band->GetXSize() ); SetRows( band->GetYSize() ); ring.addPoint(GetLeft(), GetTop()); ring.addPoint(GetLeft(), GetTop() + (GetCellHeight() * GetRows())); ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop() + (GetCellHeight() * GetRows())); ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop()); ring.closeRings(); } else { if ((GetLeft() + GetCols() > band->GetXSize()) || (GetTop() + GetRows() > band->GetYSize())) { QString sErr = QString("Invalid origin ( %1, %2 ) and size ( %5, %6 ) for file: %7") .arg(GetLeft()) .arg(GetTop()) .arg(GetCols()) .arg(GetRows()) .arg(FilePath()); throw RasterManagerException(INPUT_FILE_NOT_VALID, sErr); } double xMapOrigin = GetLeft() + (GetLeft() * GetCellWidth()); double yMapOrigin = GetTop() + (GetTop() * GetCellHeight()); ring.addPoint(xMapOrigin, yMapOrigin); ring.addPoint(xMapOrigin, yMapOrigin + (GetCellHeight() * GetRows())); ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin + (GetCellHeight() * GetRows())); ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin); ring.closeRings(); } GDALClose(ds); }