void DirectoryEntry::getDirectory(const String& path, const Dictionary& options, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) { FileSystemFlags flags(options); RefPtr<ErrorCallback> errorCallback(errorCallbackRef); if (!m_fileSystem->getDirectory(this, path, flags, successCallback, errorCallback)) filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR)); }
void Udisks2Lister::UnmountDevice(const QString& id) { QReadLocker locker(&device_data_lock_); if (!device_data_.contains(id)) return; OrgFreedesktopUDisks2FilesystemInterface filesystem( udisks2_service_, device_data_[id].dbus_path, QDBusConnection::systemBus()); if (filesystem.isValid()) { auto unmount_result = filesystem.Unmount(QVariantMap()); unmount_result.waitForFinished(); if (unmount_result.isError()) { qLog(Warning) << "Failed to unmount " << id << ": " << unmount_result.error(); return; } OrgFreedesktopUDisks2DriveInterface drive(udisks2_service_, device_data_[id].dbus_drive_path, QDBusConnection::systemBus()); if (drive.isValid()) { auto eject_result = drive.Eject(QVariantMap()); eject_result.waitForFinished(); if (eject_result.isError()) qLog(Warning) << "Failed to eject " << id << ": " << eject_result.error(); } device_data_.remove(id); DeviceRemoved(id); } }
void Renderer::load_program(const std::string& name, shader_program_t program_type) { const std::string src_vert_path(name + ".vsh"); const std::string src_frag_path(name + ".fsh"); utils::bytearray_sptr_t src_vert = filesystem().load_asset(src_vert_path); if (!src_vert) LOG(FATAL) << "Ошибка загрузки шейдера " << src_vert_path; utils::bytearray_sptr_t src_frag = filesystem().load_asset(src_frag_path); if (!src_frag) LOG(FATAL) << "Ошибка загрузки шейдера " << src_frag_path; ShaderProgramSPtr &program = m_shader_programs[program_type]; if (program) { program->initialize(*src_vert, *src_frag); } else { program.reset(new ShaderProgram(*src_vert, *src_frag)); } }
core::AppState ShaderTool::onRunning() { if (_argc != 3) { _exitCode = 1; Log::error("Usage: %s <path/to/glslangvalidator> <shaderfile>", _argv[0]); return core::AppState::Cleanup; } const std::string glslangValidatorBin = _argv[1]; Log::debug("Using glslangvalidator binary: %s", glslangValidatorBin.c_str()); const std::string shaderfile = _argv[2]; Log::debug("Preparing shader file %s", shaderfile.c_str()); const std::string fragmentFilename = shaderfile + FRAGMENT_POSTFIX; const std::string fragmentBuffer = filesystem()->load(fragmentFilename); if (fragmentBuffer.empty()) { Log::error("Could not load %s", fragmentFilename.c_str()); _exitCode = 1; return core::AppState::Cleanup; } const std::string vertexFilename = shaderfile + VERTEX_POSTFIX; const std::string vertexBuffer = filesystem()->load(vertexFilename); if (vertexBuffer.empty()) { Log::error("Could not load %s", vertexFilename.c_str()); _exitCode = 1; return core::AppState::Cleanup; } video::Shader shader; const std::string& fragmentSource = shader.getSource(video::ShaderType::SHADER_FRAGMENT, fragmentBuffer); const std::string& vertexSource = shader.getSource(video::ShaderType::SHADER_VERTEX, vertexBuffer); Log::debug("Writing shader file %s to %s", shaderfile.c_str(), filesystem()->homePath().c_str()); std::string finalFragmentFilename = _appname + "-" + fragmentFilename; std::string finalVertexFilename = _appname + "-" + vertexFilename; filesystem()->write(finalFragmentFilename, fragmentSource); filesystem()->write(finalVertexFilename, vertexSource); Log::debug("Validating shader file %s", shaderfile.c_str()); std::vector<std::string> fragmentArgs; fragmentArgs.push_back(filesystem()->homePath() + finalFragmentFilename); int fragmentValidationExitCode = core::Process::exec(glslangValidatorBin, fragmentArgs); std::vector<std::string> vertexArgs; vertexArgs.push_back(filesystem()->homePath() + finalVertexFilename); int vertexValidationExitCode = core::Process::exec(glslangValidatorBin, vertexArgs); if (fragmentValidationExitCode != 0) { _exitCode = fragmentValidationExitCode; } else if (vertexValidationExitCode != 0) { _exitCode = vertexValidationExitCode; } return core::AppState::Cleanup; }
void DirectoryReader::readEntries(EntriesCallback* entriesCallback, ErrorCallback* errorCallback) { if (!m_isReading) { m_isReading = true; filesystem()->readDirectory(this, m_fullPath, new EntriesCallbackHelper(this), new ErrorCallbackHelper(this)); } if (m_error) { filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), m_error); return; } if (m_entriesCallback) { // Non-null m_entriesCallback means multiple readEntries() calls are made // concurrently. We don't allow doing it. filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), FileError::kInvalidStateErr); return; } if (!m_hasMoreEntries || !m_entries.isEmpty()) { if (entriesCallback) DOMFileSystem::scheduleCallback( filesystem()->getExecutionContext(), createSameThreadTask(&EntriesCallback::handleEvent, wrapPersistent(entriesCallback), PersistentHeapVector<Member<Entry>>(m_entries))); m_entries.clear(); return; } m_entriesCallback = entriesCallback; m_errorCallback = errorCallback; }
void DeviceWidget::changeAutoMount(bool checked){ //auto-mount option changed QString AMFILE= QDir::homePath() + "/.pc-automounttray"; qDebug() << "Auto-mount toggled for:" << node() << checked; QString entry = label()+":::"+type()+":::"+filesystem(); if(checked){ //Add this entry to the auto-mount file QString cmd = "echo \""+entry+"\" >> "+AMFILE; system( cmd.toUtf8() ); }else{ //Remove this entry from the automount file QString tmpFile = AMFILE+".tmp"; QString cmd = "cat "+AMFILE+" | grep -v "+entry+" > "+tmpFile+"; mv "+tmpFile+" "+AMFILE; system( cmd.toUtf8() ); } }
void DeviceWidget::mountButtonClicked(){ //mount/unmount the device (based on current status) if(isMounted){ QString res = pcbsd::Utils::runShellCommand("pc-sysconfig \"unmount "+node()+"\"").join(""); if(res.simplified()!="[SUCCESS]"){ //Can add additional types of error parsing later (TO-DO) //See if the user wants to try and force the unmount if(QMessageBox::Yes == QMessageBox::question(0, tr("Device Busy"), tr("The device appears to be busy. Do you want to forcibly unmount the device?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)){ res = pcbsd::Utils::runShellCommand("pc-sysconfig \"unmount "+node()+" force\"").join(""); }else{ return; //don't show the result message if the action was cancelled } } //Now parse the output and emit the proper signals if(res=="[SUCCESS]"){ QuickUpdate(false); //quickly update the UI with the new mount status }else{ QMessageBox::warning(this, tr("Unmount Error"), tr("The device could not be unmounted. Please try again later") ); } }else{ //Device unmounted, need to mount it QString fs = filesystem(); if(fs=="NONE"){ //prompt for what filesystem to try and use to mount the device QStringList fslist = pcbsd::Utils::runShellCommand("pc-sysconfig supportedfilesystems").join("").split(", "); bool ok = false; fs = QInputDialog::getItem(0,tr("No Filesystem Detected"), tr("Select a filesystem to try:"), fslist, 0, false, &ok); if(!ok){ return; } //cancelled } //Now try to mount the device QString res = pcbsd::Utils::runShellCommand("pc-sysconfig \"mount "+node()+" "+fs+"\"").join(""); if(res.startsWith("[SUCCESS]")){ //Save the mountpoint for use later (return format: "[SUCCESS] <mountpoint>" ui->tool_run->setWhatsThis( res.section("]",1,20).simplified() ); QuickUpdate(true); }else{ qDebug() << node()+":" << res; QString err = tr("The device could not be mounted. Please try again later."); QMessageBox::warning(0,tr("Device Mounting Error"), err); } } //end of mount detection emit RefreshDeviceList(); }
EntrySyncHeapVector DirectoryReaderSync::readEntries(ExceptionState& exceptionState) { if (!m_callbacksId) { m_callbacksId = filesystem()->readDirectory(this, m_fullPath, new EntriesCallbackHelper(this), new ErrorCallbackHelper(this), DOMFileSystemBase::Synchronous); } if (m_errorCode == FileError::OK && m_hasMoreEntries && m_entries.isEmpty()) m_fileSystem->waitForAdditionalResult(m_callbacksId); if (m_errorCode != FileError::OK) { FileError::throwDOMException(exceptionState, m_errorCode); return EntrySyncHeapVector(); } EntrySyncHeapVector result; result.swap(m_entries); return result; }
Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData( const QDBusObjectPath& path) { PartitionData result; OrgFreedesktopUDisks2FilesystemInterface filesystem( udisks2_service_, path.path(), QDBusConnection::systemBus()); OrgFreedesktopUDisks2BlockInterface block(udisks2_service_, path.path(), QDBusConnection::systemBus()); if (filesystem.isValid() && block.isValid() && !filesystem.mountPoints().empty()) { OrgFreedesktopUDisks2DriveInterface drive( udisks2_service_, block.drive().path(), QDBusConnection::systemBus()); if (drive.isValid() && drive.mediaRemovable()) { result.dbus_path = path.path(); result.dbus_drive_path = block.drive().path(); result.serial = drive.serial(); result.vendor = drive.vendor(); result.model = drive.model(); result.label = block.idLabel(); result.uuid = block.idUUID(); result.capacity = drive.size(); if (!result.label.isEmpty()) result.friendly_name = result.label; else result.friendly_name = result.model + " " + result.uuid; for (const auto& path : filesystem.mountPoints()) result.mount_paths.push_back(path); result.free_space = Utilities::FileSystemFreeSpace(result.mount_paths.at(0)); } } return result; }
// == PRIVATE FUNCTIONS == void DeviceWidget::doUpdate(){ bool firstrun = type().isEmpty(); //qDebug() << "Update Item:" << firstrun << quickupdates << node(); if(firstrun || !quickupdates){ QStringList info = pcbsd::Utils::runShellCommand("pc-sysconfig \"devinfo "+node()+"\"").join("").split(", "); if(info.length() < 3){ emit RefreshDeviceList(); return; } //invalid device - will probably get removed here in a moment //Info Output: <filesystem>, <label>, <type> //qDebug() << " - info:" << info; //Save this into the internal variables ui->label_icon->setWhatsThis(info[2]); //type ui->label_dev->setText(info[1]); //label ui->tool_mount->setWhatsThis(info[0]); //filesystem if(info[0].toLower()=="zfs"){ ui->label_icon->setToolTip(node()+" ("+info[0]+")"); } else{ ui->label_icon->setToolTip("/dev/"+node()+" ("+info[0]+")"); } //Now go through and set all the various icons and such QString icon = ":icons/%1.png"; if(type()=="SATA"){ icon = icon.arg("harddrive"); } else if(type()=="USB"){ icon = icon.arg("usb"); } else if(type()=="SD"){ icon = icon.arg("sdcard"); } else if(type()=="CD-AUDIO"){ icon = icon.arg("musiccd"); } else if(type()=="CD-VIDEO"){ icon = icon.arg("cd-video"); } else if(type().startsWith("CD")){ icon = icon.arg("cd-generic"); } else if(type()=="ISO"){ icon = icon.arg("dvd"); } else{ icon = icon.arg("CDdevices"); } if(filesystem()=="NONE" && !type().startsWith("CD")){ //Add the question-mark overlay to the icon, signifying that it is an unknown filesystem QPixmap tmp(icon); QPixmap overlay(":icons/question-overlay.png"); QPainter paint(&tmp); paint.drawPixmap(ui->label_icon->width()-20, ui->label_icon->height()-20, overlay ); //put it in the bottom-right corner ui->label_icon->setPixmap(tmp); }else{ //Just the normal icon ui->label_icon->setPixmap(QPixmap(icon)); } if(type()=="CD-AUDIO" || type()=="CD-VIDEO"){ ui->tool_run->setIcon(QIcon(":icons/play.png")); ui->tool_run->setText(tr("Play")); }else{ ui->tool_run->setIcon(QIcon(":icons/folder.png") ); ui->tool_run->setText(tr("Browse")); } ui->tool_tray->setVisible(type().startsWith("CD")); //This is a CD tray canmount = filesystem()!="NONE" || !type().startsWith("CD"); //has a detected filesystem or is not a CD ui->tool_mount->setVisible(canmount); ui->check_auto->setVisible(canmount && !type().startsWith("CD")); } //Update the status of the mount button (TO DO - special ISO handling) if(isMounted){ ui->tool_mount->setText(tr("Unmount")); ui->tool_mount->setIcon(QIcon(":icons/eject.png")); QString devsize = pcbsd::Utils::runShellCommand("pc-sysconfig \"devsize "+node()+"\"").join(""); if(devsize.contains("??")){ ui->progressBar->setRange(0,0); }else{ ui->progressBar->setRange(0,100); ui->progressBar->setValue(devsize.section("(",1,1).section("%",0,0).toInt()); ui->progressBar->setToolTip(devsize); } }else{ ui->tool_mount->setText(tr("Mount")); ui->tool_mount->setIcon(QIcon(":icons/mount.png")); } ui->label_icon->setEnabled(isMounted || !canmount); ui->tool_run->setVisible( (isMounted && !mountpoint().isEmpty()) || type()=="CD-AUDIO" || type()=="CD-VIDEO" ); //if it is mounted, it can also be run ui->progressBar->setVisible(isMounted && ui->progressBar->maximum()==100); if(firstrun){ if(canmount && !type().startsWith("CD") ){ //Load auto-mount database and act appropriately QString AMFILE = QDir::homePath() + "/.pc-automounttray"; if(QFile::exists(AMFILE)){ QString cmd = "cat "+AMFILE; QString search = label() +" "+ type()+" "+ filesystem(); bool amount = !pcbsd::Utils::runShellCommandSearch(cmd, search).isEmpty(); ui->check_auto->setChecked(amount); if(amount){ mountButtonClicked(); if(isMounted){ emit ShowMessage(tr("Device Mounted"), QString(tr("%1 has been automatically mounted on %2")).arg(label(), mountpoint()) ); runButtonClicked(); //also open the directory } } } }else if(canmount){ //This is some kind of optical disk that can also be mounted (Blueray/DVD, or data disk for instance) if(type()!="CD-DATA"){ runButtonClicked(); } //not a pure data disk - go ahead and prompt to run it }else if(autoplay){ //Always try to "play" a non-mountable device when it is first connected (AUDIO/VIDEO CD usually) runButtonClicked(); } } }
void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const { RefPtr<ErrorCallback> errorCallback(errorCallbackRef); if (!m_fileSystem->getParent(this, successCallback, errorCallback)) filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR)); }
void Entry::copyTo(PassRefPtr<DirectoryEntry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const { RefPtr<ErrorCallback> errorCallback(errorCallbackRef); if (!m_fileSystem->copy(this, parent.get(), name, successCallback, errorCallback)) filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR)); }
// Operations dealing with encrypted space are done here - the volume is swapped to allow this bool ParsePartitionData(SPartition& _rPartition) { bool ParsedOK = true; // Switch out the main volume temporarily IVolume *OldVolume = m_Disc; // Ready some stuff m_Disc = CreateVolumeFromFilename(m_Filename, _rPartition.GroupNumber, _rPartition.Number); if (m_Disc == nullptr) { ERROR_LOG(DISCIO, "Failed to create volume from file %s", m_Filename.c_str()); m_Disc = OldVolume; return false; } std::unique_ptr<IFileSystem> filesystem(CreateFileSystem(m_Disc)); if (!filesystem) { ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", _rPartition.GroupNumber, _rPartition.Number); ParsedOK = false; } else { // Mark things as used which are not in the filesystem // Header, Header Information, Apploader ReadFromVolume(0x2440 + 0x14, 4, _rPartition.Header.ApploaderSize, true); ReadFromVolume(0x2440 + 0x18, 4, _rPartition.Header.ApploaderTrailerSize, true); MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset , 0 , 0x2440 + _rPartition.Header.ApploaderSize + _rPartition.Header.ApploaderTrailerSize); // DOL ReadFromVolume(0x420, 4, _rPartition.Header.DOLOffset, true); _rPartition.Header.DOLSize = GetDOLSize(_rPartition.Header.DOLOffset); MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset , _rPartition.Header.DOLOffset , _rPartition.Header.DOLSize); // FST ReadFromVolume(0x424, 4, _rPartition.Header.FSTOffset, true); ReadFromVolume(0x428, 4, _rPartition.Header.FSTSize, true); MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset , _rPartition.Header.FSTOffset , _rPartition.Header.FSTSize); // Go through the filesystem and mark entries as used for (SFileInfo file : filesystem->GetFileList()) { DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); // Just 1byte for directory? - it will end up reserving a cluster this way if (file.m_NameOffset & 0x1000000) MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset, file.m_Offset, 1); else MarkAsUsedE(_rPartition.Offset + _rPartition.Header.DataOffset, file.m_Offset, file.m_FileSize); } } // Swap back delete m_Disc; m_Disc = OldVolume; return ParsedOK; }
void DirectoryEntry::removeRecursively(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const { RefPtr<ErrorCallback> errorCallback(errorCallbackRef); if (!m_fileSystem->removeRecursively(this, successCallback, errorCallback)) filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR)); }
void DirectoryEntry::getFile(const String& path, PassRefPtr<WebKitFlags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) { RefPtr<ErrorCallback> errorCallback(errorCallbackRef); if (!m_fileSystem->getFile(this, path, flags, successCallback, errorCallback)) filesystem()->scheduleCallback(errorCallback.release(), FileError::create(FileError::INVALID_MODIFICATION_ERR)); }
void FileEntry::file(PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) { filesystem()->createFile(this, successCallback, errorCallback); }
void SAppBase::init() { // setup logging dlog.add(new dlogprinterfile(Path::localSettings(Path("log.txt")))); derr.add(new dlogprinterfile(Path::localSettings(Path("errors.txt")))); loadConfig("options.ini", true); m_options = &config("options.ini"); loadConfig("ui.ini", true); m_ui = &config("ui.ini"); loadConfig("materials.ini"); m_materials = &config("materials.ini"); std::string uistylesConfigName = m_options->get("UI", "StyleFile", std::string("uistyles.ini")); loadConfig(uistylesConfigName); m_uiStyles = &config(uistylesConfigName); // Heap debugging if (hasCmdLineOption("heapdebug")) { #if IS_MSVC int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; _CrtSetDbgFlag( tmpFlag ); #else throw("Heap debugging is only enabled in MSVC builds."); #endif } // create log dlog << m_appName << " - " << getCPUVendorID() << " " << getCPUTicksPerSecond() / 1000000.0f << " Mhz" << dlog.endl; // get default window icon, if available // tbd:mingw: fix //HICON groupIcon = LoadIcon(GetModuleHandle(0), "APP"); // Register the window class. WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, StaticMsgProc, 0L, sizeof(LONG), GetModuleHandle(NULL), /*groupIcon*/0, LoadCursor(0, IDC_ARROW), NULL, NULL, m_appName.c_str(), NULL }; RegisterClassEx( &wc ); //FreeResource(groupIcon); // Create the application's window. m_hWnd = CreateWindow( m_appName.c_str(), m_appName.c_str(), WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, GetDesktopWindow(), NULL, wc.hInstance, NULL ); if (!m_hWnd) throwf("Couldn't create a window."); // setup device bool windowed = hasCmdLineOption("w"); Point2i fullscreenSize = options().get("Render", "FullscreenSize", Point2i(1024, 768)); Point2i windowedSize = options().get("Render", "WindowedSize", Point2i(640, 480)); D3D().newDevice( windowed, fullscreenSize.x, fullscreenSize.y, windowedSize.x, windowedSize.y ); createFonts(); // create dialog mgr m_pDlgMgrSingleton = new SDialogMgr; if (!Input().create(GetModuleHandle(NULL))) throwf("Couldn't create input"); if (!Input().createMouse(m_hWnd)) throwf("Couldn't create mouse"); // setup ui DialogMgr().create(); m_textureAnimation = new TextureAnimationManager("animations.ini"); m_particles = new ParticleFactory("particles.ini", m_textureAnimation->set("particles")); m_spriteFX = new SpriteFXFactory("spritefx.ini"); timer().restart(); m_updateLoopFreq = options().get("Game", "UpdateLoopFreq", 0.0f); // create sound std::string soundProvider = options().get("Sound", "Provider", std::string("FMODProvider")); dlog << "AppBase: Initialising sound provider '" << soundProvider << "'" << dlog.endl; m_sound = (ISoundProvider*)Base::newObject(soundProvider); if (!m_sound) throwf("Couldn't initialize sound provider '" + soundProvider + "'"); // music manager loadConfig("music.ini"); loadConfig("musicmanager.ini"); m_music = new MusicManager; // Add sounds path filesystem().addFileMethod(new FileMethodDiskRelative(pathResources() + m_options->get("Sound", "SoundsPath", std::string("media\\sounds")))); // make main loop update thread #if USE_FIBERS m_mainLoopStep = new ThreadStepper(ThreadStepper::Delegate(this, (ThreadStepper::Delegate::FuncType)&SAppBase::doMainLoopUpdate)); add(*m_mainLoopStep); #endif }
File* FileEntrySync::file(ExceptionState& exceptionState) { return filesystem()->createFile(this, exceptionState); }
void FileEntry::file(BlobCallback* successCallback, ErrorCallback* errorCallback) { filesystem()->createFile(this, successCallback, errorCallback); }
void FileEntry::createWriter(FileWriterCallback* successCallback, ErrorCallback* errorCallback) { filesystem()->createWriter(this, successCallback, errorCallback); }
void FileEntry::file(PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback>) { filesystem()->scheduleCallback(successCallback, File::create(filesystem()->asyncFileSystem()->virtualToPlatformPath(m_fullPath))); }
void FilesManager::SendDrivesList() const { string drivesListstr; int dr_type; char dr_avail[256]; char *temp = dr_avail; /* 1st we fill the buffer */ GetLogicalDriveStrings(256, dr_avail); while (*temp != NULL) { string drive; drive += temp; drive += "|"; dr_type = GetDriveType(temp); switch (dr_type) { case DRIVE_UNKNOWN: drive += "Unknown Drive type"; break; case DRIVE_NO_ROOT_DIR: drive += "Drive is invalid"; break; case DRIVE_REMOVABLE: drive += "Removable Drive"; break; case DRIVE_FIXED: drive += "Hard Disk"; break; case DRIVE_REMOTE: drive += "Network Drive"; break; case DRIVE_CDROM: drive += "CD-DVD Rom"; break; case DRIVE_RAMDISK: drive += "Ram Drive"; break; } unique_ptr<char[]> volumeName(new char[MAX_PATH]); unique_ptr<char[]> filesystem(new char[MAX_PATH]); DWORD serialNumber = 0; DWORD maxComponentLen = 0; DWORD fileSystemFlags = 0; if (!GetVolumeInformation(temp, volumeName.get(), MAX_PATH, &serialNumber, &maxComponentLen, &fileSystemFlags, filesystem.get(), MAX_PATH)) { strcpy_s(volumeName.get(), 10, "error"); strcpy_s(filesystem.get(), 10, "error"); } drive += "|"; drive += volumeName.get(); drive += "|"; drive += filesystem.get(); temp += lstrlen(temp) + 1; // incriment the buffer if (drivesListstr == "") { drivesListstr += drive; } else { drivesListstr += "|#|"; drivesListstr += drive; } packetBuilder *bld = new packetBuilder(_filesManager, drivesList); bld->WriteData((unsigned char*)drivesListstr.c_str(), drivesListstr.length(), _string); bld->FinalizePacket(); // m_sendSerializedPacketCallback(bld->GetSerializedPacket(), bld->GetPacketSize()); SendPacketCallback(bld); volumeName.reset(); filesystem.reset(); // delete bld; } }
// Operations dealing with encrypted space are done here - the volume is swapped to allow this bool ParsePartitionData(SPartition& partition) { bool parsed_ok = true; // Switch out the main volume temporarily std::unique_ptr<IVolume> old_volume; s_disc.swap(old_volume); // Ready some stuff s_disc = CreateVolumeFromFilename(m_Filename, partition.GroupNumber, partition.Number); if (s_disc == nullptr) { ERROR_LOG(DISCIO, "Failed to create volume from file %s", m_Filename.c_str()); s_disc.swap(old_volume); return false; } std::unique_ptr<IFileSystem> filesystem(CreateFileSystem(s_disc.get())); if (!filesystem) { ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", partition.GroupNumber, partition.Number); parsed_ok = false; } else { // Mark things as used which are not in the filesystem // Header, Header Information, Apploader parsed_ok = parsed_ok && ReadFromVolume(0x2440 + 0x14, partition.Header.ApploaderSize, true); parsed_ok = parsed_ok && ReadFromVolume(0x2440 + 0x18, partition.Header.ApploaderTrailerSize, true); MarkAsUsedE(partition.Offset + partition.Header.DataOffset, 0, 0x2440 + partition.Header.ApploaderSize + partition.Header.ApploaderTrailerSize); // DOL partition.Header.DOLOffset = filesystem->GetBootDOLOffset(); partition.Header.DOLSize = filesystem->GetBootDOLSize(partition.Header.DOLOffset); parsed_ok = parsed_ok && partition.Header.DOLOffset && partition.Header.DOLSize; MarkAsUsedE(partition.Offset + partition.Header.DataOffset, partition.Header.DOLOffset, partition.Header.DOLSize); // FST parsed_ok = parsed_ok && ReadFromVolume(0x424, partition.Header.FSTOffset, true); parsed_ok = parsed_ok && ReadFromVolume(0x428, partition.Header.FSTSize, true); MarkAsUsedE(partition.Offset + partition.Header.DataOffset, partition.Header.FSTOffset, partition.Header.FSTSize); // Go through the filesystem and mark entries as used for (SFileInfo file : filesystem->GetFileList()) { DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); if ((file.m_NameOffset & 0x1000000) == 0) MarkAsUsedE(partition.Offset + partition.Header.DataOffset, file.m_Offset, file.m_FileSize); } } // Swap back s_disc.swap(old_volume); return parsed_ok; }
FileWriterSync* FileEntrySync::createWriter(ExceptionState& exceptionState) { return filesystem()->createWriter(this, exceptionState); }
void FileEntry::createWriter(PassRefPtr<FileWriterCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) { filesystem()->createWriter(this, successCallback, errorCallback); }