Example #1
0
std::string path_context (std::string classe, std::string _url){
	string url;
	if ( _url == "" )
		url = path_absolute(".");
	else
		url = path_absolute(_url);

	Filesystem fs;
	TiObj aux;

	while (true){
		if ( url.size() == 0 )
			return "";
		aux.set( "class", fs.folder_type(url) );
		if ( aux.is(classe) ){
			break;
		}

		if ( url == "/" ){
			return "";
		} else {
			int i;
			for ( i=url.size()-1; i>0; i--){
				if ( url[i] == '/' ){
					break;
				}
			}
			if ( i == 0 )
				url.resize(1);
			else
				url.resize(i);
		}
	}
	return url;
}
Example #2
0
void CUDisks2Provider::GetDisks(VECSOURCES &devices, bool enumerateRemovable)
{
  for (const auto &elt: m_filesystems)
  {
    Filesystem *fs = elt.second;
    if (fs->IsApproved() && fs->m_block->m_isSystem != enumerateRemovable)
      devices.push_back(fs->ToMediaShare());
  }
}
Example #3
0
void    Server::saveClientId(Client *client)
{
  const ClientInfo      &clInfo = client->getInfo();
  const ClientEntity    &clEnt = client->getEntity();
  const std::string     &clId = clInfo.getId();
  const Vector2f        &position = clEnt.getPosition();
  const Vector2i        &chunkId = clEnt.getChunkId();

  std::fstream          file;
  std::ostringstream    newLine("");
  std::vector<std::string> content;
  std::string           line;
  bool                  found = false;
  unsigned int          lineIdx = 0;
  Filesystem		fs;

  if (!fs.exist("../", "log"))
    fs.createDirectory("../", "log");
  file.open(LOGFILE, std::ios::binary | std::ios::in);
  printv(newLine, "%;% %;% %",
         clId, chunkId.x, chunkId.y,
         position.x, position.y);
  if (!file)
    {
      file.open(LOGFILE, std::ios::binary | std::ios::out);
      if (!file)
        throw std::invalid_argument(std::string(LOGFILE) + ": File not found");
      file << newLine.str() << std::endl;
      file.close();
      return ;
    }
  while (getline(file, line))
    {
      content.push_back(line);
      if (!found && line.find(clId) != std::string::npos)
        found = true;
      else if (!found)
        ++lineIdx;
    }
  if (found)
    content[lineIdx] = newLine.str();
  else
    content.push_back(newLine.str());
  file.close();
  file.open(LOGFILE, std::ios::binary | std::ios::out);
  if (!file)
    throw std::invalid_argument(std::string("Cannot acces to the file ") + LOGFILE);
  for (auto it : content)
    file << it << std::endl;
  file.close();
}
Example #4
0
int main() {
    gfxInitDefault();
    consoleInit(GFX_TOP, NULL);
    
    Filesystem fs;
    std::string path = "pk/save/main";
    
    if( fs.isInitialized() )
        std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n";
    
    else 
        std::cout << "Failed to initialize filesystem, press START to exit.";

    while(aptMainLoop()) {
        hidScanInput();
        u32 kDown = hidKeysDown();
        
        if( fs.isInitialized() ) {
            if(kDown & KEY_X) {
                if( fs.exportSaveFile(path) )
                    std::cout << "Success! Savefile exported in " << path << ".\n";
                else 
                    std:: cout << "Failed!";
                
                waitA();
                consoleClear();
                std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n";
            }
            
            if(kDown & KEY_Y) {
                if( fs.exportSaveFile(path) )
                    std::cout << "Success! Savefile imported\n";
                else 
                    std:: cout << "Failed!";
                
                waitA();
                consoleClear();
                std::cout << "X: Export save file\nY: Inject save file\n\nSTART: Exit\n\n";
            }
        }
        
        if(kDown & KEY_START) break;
        gfxFlushBuffers();
	gfxSwapBuffers();
        gspWaitForVBlank();
    }
    
    gfxExit();
    return 0;
}
void ResourcesSerializationUtil::saveResource( Filesystem& filesystem, const Resource* savedResource, const FilePath& differentSavePath )
{
   if ( !savedResource )
   {
      return;
   }

   // see if the user doesn't want to save the resource under a different name
   FilePath savedResourcePath;
   if ( !differentSavePath.empty() )
   {
      savedResourcePath = differentSavePath;
   }
   else
   {
      savedResourcePath = savedResource->getFilePath();
   }

   std::string extension = savedResourcePath.extractExtension();
   std::ios_base::openmode accessMode = Resource::getFileAccessMode( extension );
   File* file = filesystem.open( savedResourcePath, std::ios_base::out | accessMode );

   if ( !file )
   {
      return;
   }

   // save the resource
   OutFileStream outStream( file );
   ReflectionSaver saver( outStream );
   saver.save( savedResource );
}
Example #6
0
bool CUDisks2Provider::Eject(const std::string &mountpath)
{
  std::string path(mountpath);
  URIUtils::RemoveSlashAtEnd(path);

  for (const auto &elt: m_filesystems)
  {
    Filesystem *fs = elt.second;
    if (fs->m_mountPoint == path)
    {
      return fs->Unmount();
    }
  }

  return false;
}
Example #7
0
void TamyEditor::setupResourcesManager( const char* fsRoot )
{
   ResourcesManager& resMgr = ResourcesManager::getInstance();

   // setup the file system - it's paramount this works before anything in the application gets set up
   Filesystem* fs = new Filesystem( fsRoot );
   fs->setShortcut( "editorIcons", "/Editor/Icons/" );
   resMgr.setFilesystem( fs );
   fs->attach( *this );

   // register external resources
   resMgr.addImporter< FBXSceneLoader, Model >( "fbx" );
   resMgr.addImporter< BVHModelLoader, Model >( "bvh" );
   resMgr.addImporter< BVHSkeletonAnimationLoader, SkeletonAnimation >( "bvh" );
   resMgr.addImporter< IWFScene, Model >( "iwf" );
   resMgr.addImporter< ColladaScene, Model >( "dae" );
   resMgr.setProgressObserver< ProgressDialog >();
}
extern "C" int luaopen_love_filesystem(lua_State *L)
{
	Filesystem *instance = instance();
	if (instance == nullptr)
	{
		luax_catchexcept(L, [&](){ instance = new physfs::Filesystem(); });
	}
	else
		instance->retain();

	// The love loaders should be tried after package.preload.
	love::luax_register_searcher(L, loader, 2);
	love::luax_register_searcher(L, extloader, 3);

	WrappedModule w;
	w.module = instance;
	w.name = "filesystem";
	w.type = MODULE_FILESYSTEM_ID;
	w.functions = functions;
	w.types = types;

	return luax_register_module(L, w);
}
Example #9
0
void ProjectLeafNode::setEntryIcon( const Filesystem& fs, TreeWidgetDescFactory& itemsFactory )
{
   std::string iconsDir = fs.getShortcut( "editorIcons" );
   std::string extension = FilesystemUtils::extractExtension( m_projectNodeName );

   QIcon icon;

   const SerializableReflectionType* resourceType = Resource::findResourceClass( extension.c_str() );
   if ( resourceType )
   {
      // as the first shot, try creating an icon corresponding to the type of the resource
      QString typeName, group;
      itemsFactory.getDesc( *resourceType, typeName, group, icon );
   }

   if ( icon.isNull() )
   {
      // if the resource is of an unknown type, try finding an icon matching the file extension
      std::string iconName = iconsDir + "/" + extension + "Icon.png";
      if ( fs.doesExist( fs.toRelativePath( iconName ) ) )
      {
         icon = QIcon( iconName.c_str() );
      }
   }

   if ( icon.isNull() )
   {
      // as a last resort, try using a system icon
      QFileIconProvider iconProvider;

      std::string absolutePath = fs.toAbsolutePath( getRelativePath() );
      QFileInfo fileInfo( absolutePath.c_str() );
      icon = iconProvider.icon( fileInfo );
   }

   setIcon( 0, icon );
}
Example #10
0
void ProjectLeafNode::setEntrySize( const Filesystem& fs )
{
   std::string relativePath = getRelativePath();

   std::size_t fileSize = 0;
   File* file = fs.open( relativePath );
   if ( file )
   {
      fileSize = file->size();
      delete file;
   }
   else
   {
      fileSize = 0;
   }

   char fileSizeStr[ 32 ];
   sprintf_s( fileSizeStr, "%d", fileSize );
   setText( 1, fileSizeStr );
}
Example #11
0
Inode::Inode(int blockaddress, Filesystem filesystem) {
    Block *block;
    byte* pbyte;
    filesystem.getBlock(blockaddress, block);
    
    this->address = blockaddress;
    
    //ambil empat byte pertama untuk atribut file
    pbyte = (*block).getBytes(0, 4);
    type = ByteUtil::bytesToInt(pbyte);
    delete[] pbyte;
    //ambil empat byte kedua untuk filesize
    pbyte = block->getBytes(4, 4);
    filesize = ByteUtil::bytesToInt(pbyte);
    delete[] pbyte;
    //ambil tiap empat byte berikutnya untuk alamat blok file disimpan
    for(int i=0;i<MAX_ADDRESS_COUNT;i++) {
        pbyte = block->getBytes(i*4+8,4);        
        dataaddress[i] = ByteUtil::bytesToInt(pbyte);        
        delete[] pbyte;
    }
}
 void SetUp() override {
     filename = filesystem.pathToResources() + "entity.xml";
     entities.registerComponent("MockComponent", new MockComponent());
 }