Example #1
0
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;
}
Example #2
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);
}
Example #3
0
			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;
			}
Example #4
0
// 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());
}
Example #5
0
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);
}
Example #7
0
// 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;
}
Example #8
0
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}")));
    
}
Example #9
0
	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());
	}
Example #10
0
 /**
     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;
 }
Example #11
0
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);
}
Example #12
0
	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);
	}
Example #14
0
	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
		));
	}
Example #15
0
FilePath XmlDomElement::getDocFilePath() const noexcept
{
    XmlDomDocument* doc = getDocument(true);
    if (doc)
        return doc->getFilePath();
    else
        return FilePath();
}
Example #16
0
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);
}
Example #17
0
	SourceIndex::FileInfo FileInfo::getFileInfo(ConstStrW fname)
	{
		IFileIOServices &svc = IFileIOServices::getIOServices();

		PFolderIterator iter = svc.getFileInfo(fname);
		return FileInfo(FilePath(iter->getFullPath(), false), iter->getModifiedTime());

	}
Example #18
0
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() );
}
Example #19
0
//! 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;
}
Example #20
0
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);
}
Example #21
0
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");
}
Example #22
0
FilePath TextureDescriptor::GetSourceTexturePathname() const
{
    if(pathname.IsEmpty())
    {
        return FilePath();
    }

    return FilePath::CreateWithNewExtension(pathname, GetSourceTextureExtension());
}
Example #23
0
String FilePath::GetLastDirectoryName() const
{
    DVASSERT(!IsEmpty() && IsDirectoryPathname());
    
    String path = absolutePathname;
    path = path.substr(0, path.length() - 1);
    
    return FilePath(path).GetFilename();
}
Example #24
0
FileLocation SourceLocation::getSpellingLocation() const
{
   std::string file;
   unsigned line, column;
   if (getSpellingLocation(&file, &line, &column))
      return FileLocation(FilePath(file), line, column);
   else
      return FileLocation();
}
Example #25
0
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
}
Example #27
0
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;
 }
Example #29
0
// 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);
}
Example #30
0
/*
     * 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);

}