CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/UWP/UWPHelpers/StoragePickers.cpp
Views: 1401
// Copyright (c) 2023- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#include "pch.h"1819#include "StorageAsync.h"20#include "StorageAccess.h"2122using namespace Platform;23using namespace Windows::Storage;24using namespace Windows::Foundation;2526extern void AddItemToFutureList(IStorageItem^ folder);2728// Call folder picker (the selected folder will be added to future list)29concurrency::task<Platform::String^> PickSingleFolder()30{31auto folderPicker = ref new Windows::Storage::Pickers::FolderPicker();32folderPicker->SuggestedStartLocation = Windows::Storage::Pickers::PickerLocationId::Desktop;33folderPicker->FileTypeFilter->Append("*");3435return concurrency::create_task(folderPicker->PickSingleFolderAsync()).then([](StorageFolder^ folder) {36auto path = ref new Platform::String();37if (folder != nullptr)38{39AddItemToFutureList(folder);40path = folder->Path;41}42return path;43});44}4546// Call file picker (the selected file will be added to future list)47concurrency::task<Platform::String^> PickSingleFile(std::vector<std::string> exts)48{49auto filePicker = ref new Windows::Storage::Pickers::FileOpenPicker();50filePicker->SuggestedStartLocation = Windows::Storage::Pickers::PickerLocationId::Desktop;51filePicker->ViewMode = Pickers::PickerViewMode::List;5253if (exts.size() > 0) {54for each (auto ext in exts) {55filePicker->FileTypeFilter->Append(ToPlatformString(ext));56}57}58else59{60filePicker->FileTypeFilter->Append("*");61}62return concurrency::create_task(filePicker->PickSingleFileAsync()).then([](StorageFile^ file) {63auto path = ref new Platform::String();64if (file != nullptr)65{66AddItemToFutureList(file);67path = file->Path;68}69return path;70});71}727374concurrency::task<std::string> ChooseFile(std::vector<std::string> exts) {75return PickSingleFile(exts).then([](Platform::String^ filePath) {76return FromPlatformString(filePath);77});78}7980concurrency::task<std::string> ChooseFolder() {81return PickSingleFolder().then([](Platform::String^ folderPath) {82return FromPlatformString(folderPath);83});8485}868788