From b1dd940d00da86dadb4cfbb7c54dad0ee39db28c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 1 Sep 2020 11:54:16 +0100 Subject: [PATCH] Allow to umount VFS. --- RomRepoMgr.Core/Filesystem/Fuse.cs | 54 +- RomRepoMgr.Core/Filesystem/Vfs.cs | 35 +- RomRepoMgr.sln.DotSettings | 4 + RomRepoMgr/Resources/Localization.Designer.cs | 1519 +++++++---------- RomRepoMgr/Resources/Localization.es.resx | 3 + RomRepoMgr/Resources/Localization.resx | 3 + RomRepoMgr/ViewModels/MainWindowViewModel.cs | 37 +- RomRepoMgr/Views/MainWindow.xaml | 7 +- 8 files changed, 723 insertions(+), 939 deletions(-) diff --git a/RomRepoMgr.Core/Filesystem/Fuse.cs b/RomRepoMgr.Core/Filesystem/Fuse.cs index 28a82f8..a0e3405 100644 --- a/RomRepoMgr.Core/Filesystem/Fuse.cs +++ b/RomRepoMgr.Core/Filesystem/Fuse.cs @@ -27,6 +27,7 @@ namespace RomRepoMgr.Core.Filesystem readonly ConcurrentDictionary _streamsCache; long _lastHandle; ConcurrentDictionary _rootDirectoryCache; + string _umountToken; public Fuse() { @@ -107,7 +108,27 @@ namespace RomRepoMgr.Core.Filesystem FillRootDirectoryCache(); if(!_rootDirectoryCache.TryGetValue(pieces[0], out long romSetId)) + { + if(pieces[0] == ".fuse_umount" && + _umountToken != null) + { + stat = new Stat + { + st_mode = FilePermissions.S_IFREG | NativeConvert.FromOctalPermissionString("0444"), + st_nlink = 1, + st_ctime = NativeConvert.ToTimeT(DateTime.UtcNow), + st_mtime = NativeConvert.ToTimeT(DateTime.UtcNow), + st_blksize = 0, + st_blocks = 0, + st_ino = 0, + st_size = 0 + }; + + return 0; + } + return Errno.ENOENT; + } if(!_romSetsCache.TryGetValue(romSetId, out RomSet romSet)) { @@ -472,8 +493,25 @@ namespace RomRepoMgr.Core.Filesystem protected override Errno OnSynchronizeHandle(string file, OpenedPathInfo info, bool onlyUserData) => Errno.EOPNOTSUPP; - protected override Errno OnSetPathExtendedAttribute(string path, string name, byte[] value, XattrFlags flags) => - Errno.EROFS; + protected override Errno OnSetPathExtendedAttribute(string path, string name, byte[] value, XattrFlags flags) + { + if(_umountToken == null) + return Errno.EROFS; + + if(path != "/.fuse_umount") + return Errno.EROFS; + + if(name != _umountToken) + return Errno.EROFS; + + if(value?.Length != 0) + return Errno.EROFS; + + _umountToken = null; + Stop(); + + return 0; + } protected override Errno OnGetPathExtendedAttribute(string path, string name, byte[] value, out int bytesWritten) @@ -1155,6 +1193,18 @@ namespace RomRepoMgr.Core.Filesystem return Errno.EOPNOTSUPP; } + [DllImport("libc", SetLastError = true)] + static extern int setxattr(string path, string name, IntPtr value, long size, int flags); + + public void Umount() + { + var rnd = new Random(); + byte[] token = new byte[64]; + rnd.NextBytes(token); + _umountToken = Base32.ToBase32String(token); + setxattr(Path.Combine(MountPoint, ".fuse_umount"), _umountToken, IntPtr.Zero, 0, 0); + } + sealed class CachedMachine { public ulong Id { get; set; } diff --git a/RomRepoMgr.Core/Filesystem/Vfs.cs b/RomRepoMgr.Core/Filesystem/Vfs.cs index 0b20a31..9c84cc1 100644 --- a/RomRepoMgr.Core/Filesystem/Vfs.cs +++ b/RomRepoMgr.Core/Filesystem/Vfs.cs @@ -1,7 +1,40 @@ +using System; +using System.Threading.Tasks; + namespace RomRepoMgr.Core.Filesystem { - public class Vfs + public class Vfs : IDisposable { + Fuse _fuse; + public static bool IsAvailable => Winfsp.IsAvailable || Fuse.IsAvailable; + + public void Dispose() => _fuse?.Dispose(); + + public event EventHandler Umounted; + + public void MountTo(string result) + { + if(Fuse.IsAvailable) + { + _fuse = new Fuse + { + MountPoint = result + }; + + Task.Run(() => + { + _fuse.Start(); + + Umounted?.Invoke(this, System.EventArgs.Empty); + }); + } + } + + public void Umount() + { + _fuse?.Umount(); + _fuse = null; + } } } \ No newline at end of file diff --git a/RomRepoMgr.sln.DotSettings b/RomRepoMgr.sln.DotSettings index 10e021d..d2f5a5a 100644 --- a/RomRepoMgr.sln.DotSettings +++ b/RomRepoMgr.sln.DotSettings @@ -1,9 +1,13 @@  True True + True + True True True True + True + True True True True diff --git a/RomRepoMgr/Resources/Localization.Designer.cs b/RomRepoMgr/Resources/Localization.Designer.cs index 53005eb..b49fb0a 100644 --- a/RomRepoMgr/Resources/Localization.Designer.cs +++ b/RomRepoMgr/Resources/Localization.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,46 +11,32 @@ namespace RomRepoMgr.Resources { using System; - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Localization { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Localization() { } - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RomRepoMgr.Resources.Localization", typeof(Localization).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("RomRepoMgr.Resources.Localization", typeof(Localization).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,988 +45,664 @@ namespace RomRepoMgr.Resources { } } - /// - /// Looks up a localized string similar to About. - /// - internal static string AboutLabel { - get { - return ResourceManager.GetString("AboutLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to About ROM Repository Manager. - /// - internal static string AboutTitle { - get { - return ResourceManager.GetString("AboutTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All files. - /// - internal static string AllFilesDialogLabel { - get { - return ResourceManager.GetString("AllFilesDialogLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Check all files.. - /// - internal static string AllFilesLabel { - get { - return ResourceManager.GetString("AllFilesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Library. - /// - internal static string AssembliesLibraryText { - get { - return ResourceManager.GetString("AssembliesLibraryText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Version. - /// - internal static string AssembliesVersionText { - get { - return ResourceManager.GetString("AssembliesVersionText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Authors. - /// - internal static string AuthorsLabel { - get { - return ResourceManager.GetString("AuthorsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Developers: - /// Natalia Portillo - ///. - /// - internal static string AuthorsText { - get { - return ResourceManager.GetString("AuthorsText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cancel. - /// - internal static string CancelLabel { - get { - return ResourceManager.GetString("CancelLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checking The Unarchiver.... - /// - internal static string CheckingUnArText { - get { - return ResourceManager.GetString("CheckingUnArText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose database to open / create. - /// - internal static string ChooseDatabaseFile { - get { - return ResourceManager.GetString("ChooseDatabaseFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose.... - /// - internal static string ChooseLabel { - get { - return ResourceManager.GetString("ChooseLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose repository folder. - /// - internal static string ChooseRepositoryFolder { - get { - return ResourceManager.GetString("ChooseRepositoryFolder", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose temporary folder. - /// - internal static string ChooseTemporaryFolder { - get { - return ResourceManager.GetString("ChooseTemporaryFolder", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Choose UnArchiver executable. - /// - internal static string ChooseUnArExecutable { - get { - return ResourceManager.GetString("ChooseUnArExecutable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close. - /// - internal static string CloseLabel { - get { - return ResourceManager.GetString("CloseLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Complete games. - /// - internal static string CompleteMachinesLabel { - get { - return ResourceManager.GetString("CompleteMachinesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An error occurred trying to delete the chosen file.. - /// - internal static string DatabaseFileCannotDeleteCaption { - get { - return ResourceManager.GetString("DatabaseFileCannotDeleteCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Could not delete file. - /// - internal static string DatabaseFileCannotDeleteTitle { - get { - return ResourceManager.GetString("DatabaseFileCannotDeleteTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do you want to delete the file?. - /// - internal static string DatabaseFileDeleteCaption { - get { - return ResourceManager.GetString("DatabaseFileDeleteCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File exists. - /// - internal static string DatabaseFileExistsMsgBoxTitle { - get { - return ResourceManager.GetString("DatabaseFileExistsMsgBoxTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Database file. - /// - internal static string DatabaseFileLabel { - get { - return ResourceManager.GetString("DatabaseFileLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do you want to try to open the existing file as a database?. - /// - internal static string DatabaseFileMsgBoxTryOpen { - get { - return ResourceManager.GetString("DatabaseFileMsgBoxTryOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do you want to try to open the existing file as a database?. - /// - internal static string DatabaseFileTryOpenCaption { - get { - return ResourceManager.GetString("DatabaseFileTryOpenCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An error occurred trying to use the chosen file as a database. - ///Do you want to delete the file?. - /// - internal static string DatabaseFileUnusableDeleteMsgBoxCaption { - get { - return ResourceManager.GetString("DatabaseFileUnusableDeleteMsgBoxCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An error occurred trying to use the chosen file as a database.. - /// - internal static string DatabaseFileUnusableMsgBoxCaption { - get { - return ResourceManager.GetString("DatabaseFileUnusableMsgBoxCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Could not use database. - /// - internal static string DatabaseFileUnusableMsgBoxTitle { - get { - return ResourceManager.GetString("DatabaseFileUnusableMsgBoxTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DAT files. - /// - internal static string DatFilesDialogLabel { - get { - return ResourceManager.GetString("DatFilesDialogLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Decompressing DAT file.... - /// - internal static string DecompressingDat { - get { - return ResourceManager.GetString("DecompressingDat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Are you sure you want to delete the ROM set {0}?. - /// - internal static string DeleteRomSetMsgBoxCaption { - get { - return ResourceManager.GetString("DeleteRomSetMsgBoxCaption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Delete ROM set. - /// - internal static string DeleteRomSetMsgBoxTitle { - get { - return ResourceManager.GetString("DeleteRomSetMsgBoxTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edit DAT. - /// - internal static string EditDatTitle { - get { - return ResourceManager.GetString("EditDatTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error. - /// - internal static string Error { - get { - return ResourceManager.GetString("Error", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Exit. - /// - internal static string ExitButtonText { - get { - return ResourceManager.GetString("ExitButtonText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Exporting DAT file.... - /// - internal static string ExportDatTitle { - get { - return ResourceManager.GetString("ExportDatTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Export ROMs to folder.... - /// - internal static string ExportRomsDialogTitle { - get { - return ResourceManager.GetString("ExportRomsDialogTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Exporting ROM files to folder.... - /// - internal static string ExportRomsTitle { - get { - return ResourceManager.GetString("ExportRomsTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to E_xit. - /// - internal static string FileMenuExitText { - get { - return ResourceManager.GetString("FileMenuExitText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import DAT _file. - /// - internal static string FileMenuImportDatFileText { - get { - return ResourceManager.GetString("FileMenuImportDatFileText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import DAT f_older. - /// - internal static string FileMenuImportDatFolderText { - get { - return ResourceManager.GetString("FileMenuImportDatFolderText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _Settings. - /// - internal static string FileMenuSettingsText { - get { - return ResourceManager.GetString("FileMenuSettingsText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _File. - /// internal static string FileMenuText { get { return ResourceManager.GetString("FileMenuText", resourceCulture); } } - /// - /// Looks up a localized string similar to _Mount. - /// - internal static string FilesystemMenuMountText { - get { - return ResourceManager.GetString("FilesystemMenuMountText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File_system. - /// - internal static string FilesystemMenuText { - get { - return ResourceManager.GetString("FilesystemMenuText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finished. - /// - internal static string Finished { - get { - return ResourceManager.GetString("Finished", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Found {0} files.... - /// - internal static string FoundFiles { - get { - return ResourceManager.GetString("FoundFiles", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Have ROMs. - /// - internal static string HaveRomsLabel { - get { - return ResourceManager.GetString("HaveRomsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _About. - /// - internal static string HelpMenuAboutText { - get { - return ResourceManager.GetString("HelpMenuAboutText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _Help. - /// - internal static string HelpMenuText { - get { - return ResourceManager.GetString("HelpMenuText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Homepage. - /// - internal static string HomepageLabel { - get { - return ResourceManager.GetString("HomepageLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import DAT file.... - /// - internal static string ImportDatFileDialogTitle { - get { - return ResourceManager.GetString("ImportDatFileDialogTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import DATs from folder.... - /// - internal static string ImportDatFolderDialogTitle { - get { - return ResourceManager.GetString("ImportDatFolderDialogTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import DAT files from folder.... - /// - internal static string ImportDatFolderTitle { - get { - return ResourceManager.GetString("ImportDatFolderTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Importing DAT file.... - /// - internal static string ImportDatTitle { - get { - return ResourceManager.GetString("ImportDatTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Importing {0}.... - /// - internal static string ImportingItem { - get { - return ResourceManager.GetString("ImportingItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import ROM files from folder.... - /// - internal static string ImportRomFolderTitle { - get { - return ResourceManager.GetString("ImportRomFolderTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Import ROMs from folder.... - /// - internal static string ImportRomsFolderDialogTitle { - get { - return ResourceManager.GetString("ImportRomsFolderDialogTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Incomplete games. - /// - internal static string IncompleteMachinesLabel { - get { - return ResourceManager.GetString("IncompleteMachinesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Only import known files.. - /// - internal static string KnownOnlyLabel { - get { - return ResourceManager.GetString("KnownOnlyLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Libraries. - /// - internal static string LibrariesLabel { - get { - return ResourceManager.GetString("LibrariesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to License: GNU General Public License Version 3. - /// - internal static string LicenseLabel { - get { - return ResourceManager.GetString("LicenseLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Loading database.... - /// - internal static string LoadingDatabaseText { - get { - return ResourceManager.GetString("LoadingDatabaseText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Loading ROM sets.... - /// - internal static string LoadingRomSetsText { - get { - return ResourceManager.GetString("LoadingRomSetsText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Loading settings.... - /// - internal static string LoadingSettingsText { - get { - return ResourceManager.GetString("LoadingSettingsText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Migrating database.... - /// - internal static string MigratingDatabaseText { - get { - return ResourceManager.GetString("MigratingDatabaseText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing ROMs. - /// - internal static string MissRomsLabel { - get { - return ResourceManager.GetString("MissRomsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to OK. - /// - internal static string OK { - get { - return ResourceManager.GetString("OK", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Path:. - /// - internal static string PathLabel { - get { - return ResourceManager.GetString("PathLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Try to detect archives and import their contents.. - /// - internal static string RecurseArchivesLabel { - get { - return ResourceManager.GetString("RecurseArchivesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Recurse subfolders.. - /// - internal static string RecursiveLabel { - get { - return ResourceManager.GetString("RecursiveLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Removing ROM set.... - /// - internal static string RemoveDatTitle { - get { - return ResourceManager.GetString("RemoveDatTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove files after import successful.. - /// - internal static string RemoveFilesLabel { - get { - return ResourceManager.GetString("RemoveFilesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Removing DAT file from repo.... - /// - internal static string RemovingDatFileFromRepo { - get { - return ResourceManager.GetString("RemovingDatFileFromRepo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Removing ROM set from database.... - /// - internal static string RemovingRomSetFromDatabase { - get { - return ResourceManager.GetString("RemovingRomSetFromDatabase", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Repository folder. - /// - internal static string RepositoryFolderLabel { - get { - return ResourceManager.GetString("RepositoryFolderLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Filename. - /// - internal static string ResultFilenameLabel { - get { - return ResourceManager.GetString("ResultFilenameLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Status. - /// - internal static string ResultStatusLabel { - get { - return ResourceManager.GetString("ResultStatusLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Retrieving ROM set from database.... - /// - internal static string RetrievingRomSetFromDatabase { - get { - return ResourceManager.GetString("RetrievingRomSetFromDatabase", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Author. - /// - internal static string RomSetAuthorLabel { - get { - return ResourceManager.GetString("RomSetAuthorLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comment. - /// - internal static string RomSetCommentLabel { - get { - return ResourceManager.GetString("RomSetCommentLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Complete. - /// - internal static string RomSetCompleteMachinesLabel { - get { - return ResourceManager.GetString("RomSetCompleteMachinesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Date. - /// - internal static string RomSetDateLabel { - get { - return ResourceManager.GetString("RomSetDateLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Description. - /// - internal static string RomSetDescriptionLabel { - get { - return ResourceManager.GetString("RomSetDescriptionLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Have. - /// - internal static string RomSetHaveRomsLabel { - get { - return ResourceManager.GetString("RomSetHaveRomsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Incomplete. - /// - internal static string RomSetIncompleteMachinesLabel { - get { - return ResourceManager.GetString("RomSetIncompleteMachinesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Miss. - /// - internal static string RomSetMissRomsLabel { - get { - return ResourceManager.GetString("RomSetMissRomsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name. - /// - internal static string RomSetNameLabel { - get { - return ResourceManager.GetString("RomSetNameLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ROM sets. - /// internal static string RomSets { get { return ResourceManager.GetString("RomSets", resourceCulture); } } - /// - /// Looks up a localized string similar to _Delete. - /// - internal static string RomSetsMenuDeleteText { + internal static string RomSetNameLabel { get { - return ResourceManager.GetString("RomSetsMenuDeleteText", resourceCulture); + return ResourceManager.GetString("RomSetNameLabel", resourceCulture); } } - /// - /// Looks up a localized string similar to _Edit. - /// - internal static string RomSetsMenuEditText { - get { - return ResourceManager.GetString("RomSetsMenuEditText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Save DAT _file. - /// - internal static string RomSetsMenuSaveDatText { - get { - return ResourceManager.GetString("RomSetsMenuSaveDatText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _Save ROMs to folder. - /// - internal static string RomSetsMenuSaveRomsText { - get { - return ResourceManager.GetString("RomSetsMenuSaveRomsText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ROM _sets. - /// - internal static string RomSetsMenuText { - get { - return ResourceManager.GetString("RomSetsMenuText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Games. - /// - internal static string RomSetTotalMachinesLabel { - get { - return ResourceManager.GetString("RomSetTotalMachinesLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ROMs. - /// - internal static string RomSetTotalRomsLabel { - get { - return ResourceManager.GetString("RomSetTotalRomsLabel", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Version. - /// internal static string RomSetVersionLabel { get { return ResourceManager.GetString("RomSetVersionLabel", resourceCulture); } } - /// - /// Looks up a localized string similar to _Import folder. - /// - internal static string RomsMenuImportText { + internal static string RomSetAuthorLabel { get { - return ResourceManager.GetString("RomsMenuImportText", resourceCulture); + return ResourceManager.GetString("RomSetAuthorLabel", resourceCulture); + } + } + + internal static string RomSetDateLabel { + get { + return ResourceManager.GetString("RomSetDateLabel", resourceCulture); + } + } + + internal static string RomSetDescriptionLabel { + get { + return ResourceManager.GetString("RomSetDescriptionLabel", resourceCulture); + } + } + + internal static string RomSetCommentLabel { + get { + return ResourceManager.GetString("RomSetCommentLabel", resourceCulture); + } + } + + internal static string RomSetTotalMachinesLabel { + get { + return ResourceManager.GetString("RomSetTotalMachinesLabel", resourceCulture); + } + } + + internal static string RomSetCompleteMachinesLabel { + get { + return ResourceManager.GetString("RomSetCompleteMachinesLabel", resourceCulture); + } + } + + internal static string RomSetIncompleteMachinesLabel { + get { + return ResourceManager.GetString("RomSetIncompleteMachinesLabel", resourceCulture); + } + } + + internal static string RomSetTotalRomsLabel { + get { + return ResourceManager.GetString("RomSetTotalRomsLabel", resourceCulture); + } + } + + internal static string RomSetHaveRomsLabel { + get { + return ResourceManager.GetString("RomSetHaveRomsLabel", resourceCulture); + } + } + + internal static string RomSetMissRomsLabel { + get { + return ResourceManager.GetString("RomSetMissRomsLabel", resourceCulture); + } + } + + internal static string FileMenuImportDatFileText { + get { + return ResourceManager.GetString("FileMenuImportDatFileText", resourceCulture); + } + } + + internal static string FileMenuImportDatFolderText { + get { + return ResourceManager.GetString("FileMenuImportDatFolderText", resourceCulture); + } + } + + internal static string FileMenuSettingsText { + get { + return ResourceManager.GetString("FileMenuSettingsText", resourceCulture); + } + } + + internal static string FileMenuExitText { + get { + return ResourceManager.GetString("FileMenuExitText", resourceCulture); + } + } + + internal static string FilesystemMenuText { + get { + return ResourceManager.GetString("FilesystemMenuText", resourceCulture); + } + } + + internal static string FilesystemMenuMountText { + get { + return ResourceManager.GetString("FilesystemMenuMountText", resourceCulture); } } - /// - /// Looks up a localized string similar to _ROMs. - /// internal static string RomsMenuText { get { return ResourceManager.GetString("RomsMenuText", resourceCulture); } } - /// - /// Looks up a localized string similar to Save. - /// - internal static string SaveLabel { + internal static string RomsMenuImportText { get { - return ResourceManager.GetString("SaveLabel", resourceCulture); + return ResourceManager.GetString("RomsMenuImportText", resourceCulture); } } - /// - /// Looks up a localized string similar to Saving changes to database.... - /// - internal static string SavingChangesToDatabase { + internal static string RomSetsMenuText { get { - return ResourceManager.GetString("SavingChangesToDatabase", resourceCulture); + return ResourceManager.GetString("RomSetsMenuText", resourceCulture); } } - /// - /// Looks up a localized string similar to Searching for files.... - /// - internal static string SearchingForFiles { + internal static string RomSetsMenuSaveRomsText { get { - return ResourceManager.GetString("SearchingForFiles", resourceCulture); + return ResourceManager.GetString("RomSetsMenuSaveRomsText", resourceCulture); } } - /// - /// Looks up a localized string similar to Select mount point.... - /// - internal static string SelectMountPointDialogTitle { + internal static string RomSetsMenuSaveDatText { get { - return ResourceManager.GetString("SelectMountPointDialogTitle", resourceCulture); + return ResourceManager.GetString("RomSetsMenuSaveDatText", resourceCulture); } } - /// - /// Looks up a localized string similar to Settings. - /// - internal static string SettingsTitle { + internal static string RomSetsMenuEditText { get { - return ResourceManager.GetString("SettingsTitle", resourceCulture); + return ResourceManager.GetString("RomSetsMenuEditText", resourceCulture); } } - /// - /// Looks up a localized string similar to Start. - /// - internal static string StartLabel { + internal static string RomSetsMenuDeleteText { get { - return ResourceManager.GetString("StartLabel", resourceCulture); + return ResourceManager.GetString("RomSetsMenuDeleteText", resourceCulture); } } - /// - /// Looks up a localized string similar to Temporary folder. - /// - internal static string TemporaryFolderLabel { + internal static string HelpMenuText { get { - return ResourceManager.GetString("TemporaryFolderLabel", resourceCulture); + return ResourceManager.GetString("HelpMenuText", resourceCulture); } } - /// - /// Looks up a localized string similar to The Unarchiver version {0}. - /// - internal static string TheUnarchiverVersionLabel { + internal static string HelpMenuAboutText { get { - return ResourceManager.GetString("TheUnarchiverVersionLabel", resourceCulture); + return ResourceManager.GetString("HelpMenuAboutText", resourceCulture); + } + } + + internal static string AboutLabel { + get { + return ResourceManager.GetString("AboutLabel", resourceCulture); + } + } + + internal static string LibrariesLabel { + get { + return ResourceManager.GetString("LibrariesLabel", resourceCulture); + } + } + + internal static string AuthorsLabel { + get { + return ResourceManager.GetString("AuthorsLabel", resourceCulture); + } + } + + internal static string AboutTitle { + get { + return ResourceManager.GetString("AboutTitle", resourceCulture); + } + } + + internal static string LicenseLabel { + get { + return ResourceManager.GetString("LicenseLabel", resourceCulture); + } + } + + internal static string CloseLabel { + get { + return ResourceManager.GetString("CloseLabel", resourceCulture); + } + } + + internal static string AssembliesLibraryText { + get { + return ResourceManager.GetString("AssembliesLibraryText", resourceCulture); + } + } + + internal static string AssembliesVersionText { + get { + return ResourceManager.GetString("AssembliesVersionText", resourceCulture); + } + } + + internal static string AuthorsText { + get { + return ResourceManager.GetString("AuthorsText", resourceCulture); + } + } + + internal static string HomepageLabel { + get { + return ResourceManager.GetString("HomepageLabel", resourceCulture); } } - /// - /// Looks up a localized string similar to Total games. - /// internal static string TotalMachinesLabel { get { return ResourceManager.GetString("TotalMachinesLabel", resourceCulture); } } - /// - /// Looks up a localized string similar to Total ROMs. - /// + internal static string CompleteMachinesLabel { + get { + return ResourceManager.GetString("CompleteMachinesLabel", resourceCulture); + } + } + + internal static string IncompleteMachinesLabel { + get { + return ResourceManager.GetString("IncompleteMachinesLabel", resourceCulture); + } + } + internal static string TotalRomsLabel { get { return ResourceManager.GetString("TotalRomsLabel", resourceCulture); } } - /// - /// Looks up a localized string similar to Path to UnAr. - /// + internal static string HaveRomsLabel { + get { + return ResourceManager.GetString("HaveRomsLabel", resourceCulture); + } + } + + internal static string MissRomsLabel { + get { + return ResourceManager.GetString("MissRomsLabel", resourceCulture); + } + } + + internal static string EditDatTitle { + get { + return ResourceManager.GetString("EditDatTitle", resourceCulture); + } + } + + internal static string SaveLabel { + get { + return ResourceManager.GetString("SaveLabel", resourceCulture); + } + } + + internal static string CancelLabel { + get { + return ResourceManager.GetString("CancelLabel", resourceCulture); + } + } + + internal static string ExportDatTitle { + get { + return ResourceManager.GetString("ExportDatTitle", resourceCulture); + } + } + + internal static string DecompressingDat { + get { + return ResourceManager.GetString("DecompressingDat", resourceCulture); + } + } + + internal static string Finished { + get { + return ResourceManager.GetString("Finished", resourceCulture); + } + } + + internal static string ExportRomsTitle { + get { + return ResourceManager.GetString("ExportRomsTitle", resourceCulture); + } + } + + internal static string PathLabel { + get { + return ResourceManager.GetString("PathLabel", resourceCulture); + } + } + + internal static string AllFilesLabel { + get { + return ResourceManager.GetString("AllFilesLabel", resourceCulture); + } + } + + internal static string RecursiveLabel { + get { + return ResourceManager.GetString("RecursiveLabel", resourceCulture); + } + } + + internal static string ImportDatFolderTitle { + get { + return ResourceManager.GetString("ImportDatFolderTitle", resourceCulture); + } + } + + internal static string ResultFilenameLabel { + get { + return ResourceManager.GetString("ResultFilenameLabel", resourceCulture); + } + } + + internal static string ResultStatusLabel { + get { + return ResourceManager.GetString("ResultStatusLabel", resourceCulture); + } + } + + internal static string StartLabel { + get { + return ResourceManager.GetString("StartLabel", resourceCulture); + } + } + + internal static string SearchingForFiles { + get { + return ResourceManager.GetString("SearchingForFiles", resourceCulture); + } + } + + internal static string FoundFiles { + get { + return ResourceManager.GetString("FoundFiles", resourceCulture); + } + } + + internal static string ImportingItem { + get { + return ResourceManager.GetString("ImportingItem", resourceCulture); + } + } + + internal static string OK { + get { + return ResourceManager.GetString("OK", resourceCulture); + } + } + + internal static string ImportDatTitle { + get { + return ResourceManager.GetString("ImportDatTitle", resourceCulture); + } + } + + internal static string RemoveFilesLabel { + get { + return ResourceManager.GetString("RemoveFilesLabel", resourceCulture); + } + } + + internal static string KnownOnlyLabel { + get { + return ResourceManager.GetString("KnownOnlyLabel", resourceCulture); + } + } + + internal static string RecurseArchivesLabel { + get { + return ResourceManager.GetString("RecurseArchivesLabel", resourceCulture); + } + } + + internal static string ImportRomFolderTitle { + get { + return ResourceManager.GetString("ImportRomFolderTitle", resourceCulture); + } + } + + internal static string RemoveDatTitle { + get { + return ResourceManager.GetString("RemoveDatTitle", resourceCulture); + } + } + + internal static string RetrievingRomSetFromDatabase { + get { + return ResourceManager.GetString("RetrievingRomSetFromDatabase", resourceCulture); + } + } + + internal static string RemovingRomSetFromDatabase { + get { + return ResourceManager.GetString("RemovingRomSetFromDatabase", resourceCulture); + } + } + + internal static string SavingChangesToDatabase { + get { + return ResourceManager.GetString("SavingChangesToDatabase", resourceCulture); + } + } + + internal static string RemovingDatFileFromRepo { + get { + return ResourceManager.GetString("RemovingDatFileFromRepo", resourceCulture); + } + } + + internal static string ChooseLabel { + get { + return ResourceManager.GetString("ChooseLabel", resourceCulture); + } + } + + internal static string SettingsTitle { + get { + return ResourceManager.GetString("SettingsTitle", resourceCulture); + } + } + + internal static string DatabaseFileLabel { + get { + return ResourceManager.GetString("DatabaseFileLabel", resourceCulture); + } + } + + internal static string RepositoryFolderLabel { + get { + return ResourceManager.GetString("RepositoryFolderLabel", resourceCulture); + } + } + + internal static string TemporaryFolderLabel { + get { + return ResourceManager.GetString("TemporaryFolderLabel", resourceCulture); + } + } + internal static string UnArPathLabel { get { return ResourceManager.GetString("UnArPathLabel", resourceCulture); } } + + internal static string Error { + get { + return ResourceManager.GetString("Error", resourceCulture); + } + } + + internal static string TheUnarchiverVersionLabel { + get { + return ResourceManager.GetString("TheUnarchiverVersionLabel", resourceCulture); + } + } + + internal static string ChooseUnArExecutable { + get { + return ResourceManager.GetString("ChooseUnArExecutable", resourceCulture); + } + } + + internal static string ChooseTemporaryFolder { + get { + return ResourceManager.GetString("ChooseTemporaryFolder", resourceCulture); + } + } + + internal static string ChooseRepositoryFolder { + get { + return ResourceManager.GetString("ChooseRepositoryFolder", resourceCulture); + } + } + + internal static string ChooseDatabaseFile { + get { + return ResourceManager.GetString("ChooseDatabaseFile", resourceCulture); + } + } + + internal static string DatabaseFileMsgBoxTryOpen { + get { + return ResourceManager.GetString("DatabaseFileMsgBoxTryOpen", resourceCulture); + } + } + + internal static string DatabaseFileTryOpenCaption { + get { + return ResourceManager.GetString("DatabaseFileTryOpenCaption", resourceCulture); + } + } + + internal static string DatabaseFileExistsMsgBoxTitle { + get { + return ResourceManager.GetString("DatabaseFileExistsMsgBoxTitle", resourceCulture); + } + } + + internal static string DatabaseFileUnusableMsgBoxTitle { + get { + return ResourceManager.GetString("DatabaseFileUnusableMsgBoxTitle", resourceCulture); + } + } + + internal static string DatabaseFileUnusableDeleteMsgBoxCaption { + get { + return ResourceManager.GetString("DatabaseFileUnusableDeleteMsgBoxCaption", resourceCulture); + } + } + + internal static string DatabaseFileUnusableMsgBoxCaption { + get { + return ResourceManager.GetString("DatabaseFileUnusableMsgBoxCaption", resourceCulture); + } + } + + internal static string DatabaseFileDeleteCaption { + get { + return ResourceManager.GetString("DatabaseFileDeleteCaption", resourceCulture); + } + } + + internal static string DatabaseFileCannotDeleteTitle { + get { + return ResourceManager.GetString("DatabaseFileCannotDeleteTitle", resourceCulture); + } + } + + internal static string DatabaseFileCannotDeleteCaption { + get { + return ResourceManager.GetString("DatabaseFileCannotDeleteCaption", resourceCulture); + } + } + + internal static string ImportDatFileDialogTitle { + get { + return ResourceManager.GetString("ImportDatFileDialogTitle", resourceCulture); + } + } + + internal static string DatFilesDialogLabel { + get { + return ResourceManager.GetString("DatFilesDialogLabel", resourceCulture); + } + } + + internal static string AllFilesDialogLabel { + get { + return ResourceManager.GetString("AllFilesDialogLabel", resourceCulture); + } + } + + internal static string ImportDatFolderDialogTitle { + get { + return ResourceManager.GetString("ImportDatFolderDialogTitle", resourceCulture); + } + } + + internal static string ImportRomsFolderDialogTitle { + get { + return ResourceManager.GetString("ImportRomsFolderDialogTitle", resourceCulture); + } + } + + internal static string DeleteRomSetMsgBoxTitle { + get { + return ResourceManager.GetString("DeleteRomSetMsgBoxTitle", resourceCulture); + } + } + + internal static string DeleteRomSetMsgBoxCaption { + get { + return ResourceManager.GetString("DeleteRomSetMsgBoxCaption", resourceCulture); + } + } + + internal static string ExportRomsDialogTitle { + get { + return ResourceManager.GetString("ExportRomsDialogTitle", resourceCulture); + } + } + + internal static string SelectMountPointDialogTitle { + get { + return ResourceManager.GetString("SelectMountPointDialogTitle", resourceCulture); + } + } + + internal static string LoadingSettingsText { + get { + return ResourceManager.GetString("LoadingSettingsText", resourceCulture); + } + } + + internal static string CheckingUnArText { + get { + return ResourceManager.GetString("CheckingUnArText", resourceCulture); + } + } + + internal static string LoadingDatabaseText { + get { + return ResourceManager.GetString("LoadingDatabaseText", resourceCulture); + } + } + + internal static string MigratingDatabaseText { + get { + return ResourceManager.GetString("MigratingDatabaseText", resourceCulture); + } + } + + internal static string LoadingRomSetsText { + get { + return ResourceManager.GetString("LoadingRomSetsText", resourceCulture); + } + } + + internal static string ExitButtonText { + get { + return ResourceManager.GetString("ExitButtonText", resourceCulture); + } + } + + internal static string FilesystemMenuUmountText { + get { + return ResourceManager.GetString("FilesystemMenuUmountText", resourceCulture); + } + } } } diff --git a/RomRepoMgr/Resources/Localization.es.resx b/RomRepoMgr/Resources/Localization.es.resx index 3130dfa..753fc74 100644 --- a/RomRepoMgr/Resources/Localization.es.resx +++ b/RomRepoMgr/Resources/Localization.es.resx @@ -340,4 +340,7 @@ Ruta a UnAr + + _Desmontar + \ No newline at end of file diff --git a/RomRepoMgr/Resources/Localization.resx b/RomRepoMgr/Resources/Localization.resx index e1e2307..4fddc39 100644 --- a/RomRepoMgr/Resources/Localization.resx +++ b/RomRepoMgr/Resources/Localization.resx @@ -346,4 +346,7 @@ Do you want to delete the file? Exit + + _Umount + \ No newline at end of file diff --git a/RomRepoMgr/ViewModels/MainWindowViewModel.cs b/RomRepoMgr/ViewModels/MainWindowViewModel.cs index 56b4b73..6a82f7c 100644 --- a/RomRepoMgr/ViewModels/MainWindowViewModel.cs +++ b/RomRepoMgr/ViewModels/MainWindowViewModel.cs @@ -23,8 +23,10 @@ // Copyright © 2020 Natalia Portillo *******************************************************************************/ +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.Linq; using System.Reactive; using Avalonia; @@ -45,8 +47,8 @@ namespace RomRepoMgr.ViewModels public class MainWindowViewModel : ViewModelBase { readonly MainWindow _view; - - RomSetModel _selectedRomSet; + RomSetModel _selectedRomSet; + Vfs _vfs; public MainWindowViewModel(MainWindow view, List romSets) { @@ -62,6 +64,7 @@ namespace RomRepoMgr.ViewModels ExportDatCommand = ReactiveCommand.Create(ExecuteExportDatCommand); ExportRomsCommand = ReactiveCommand.Create(ExecuteExportRomsCommand); MountCommand = ReactiveCommand.Create(ExecuteMountCommand); + UmountCommand = ReactiveCommand.Create(ExecuteUmountCommand); RomSets = new ObservableCollection(romSets); } @@ -96,6 +99,7 @@ namespace RomRepoMgr.ViewModels public string RomSetsMenuDeleteText => Localization.RomSetsMenuDeleteText; public string HelpMenuText => Localization.HelpMenuText; public string HelpMenuAboutText => Localization.HelpMenuAboutText; + public string FilesystemMenuUmountText => Localization.FilesystemMenuUmountText; public bool NativeMenuSupported => NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as @@ -112,6 +116,13 @@ namespace RomRepoMgr.ViewModels public ReactiveCommand ExportDatCommand { get; } public ReactiveCommand ExportRomsCommand { get; } public ReactiveCommand MountCommand { get; } + public ReactiveCommand UmountCommand { get; } + + public Vfs Vfs + { + get => _vfs; + set => this.RaiseAndSetIfChanged(ref _vfs, value); + } public RomSetModel SelectedRomSet { @@ -304,6 +315,9 @@ namespace RomRepoMgr.ViewModels async void ExecuteMountCommand() { + if(Vfs != null) + return; + var dlgOpen = new OpenFolderDialog { Title = Localization.SelectMountPointDialogTitle @@ -314,12 +328,23 @@ namespace RomRepoMgr.ViewModels if(result == null) return; - var fs = new Fuse + try { - MountPoint = result - }; + Vfs = new Vfs(); + Vfs.Umounted += VfsOnUmounted; + Vfs.MountTo(result); + } + catch(Exception) + { + if(Debugger.IsAttached) + throw; - fs.Start(); + Vfs = null; + } } + + void VfsOnUmounted(object sender, EventArgs e) => Vfs = null; + + void ExecuteUmountCommand() => Vfs?.Umount(); } } \ No newline at end of file diff --git a/RomRepoMgr/Views/MainWindow.xaml b/RomRepoMgr/Views/MainWindow.xaml index 2636ed2..077e7f2 100644 --- a/RomRepoMgr/Views/MainWindow.xaml +++ b/RomRepoMgr/Views/MainWindow.xaml @@ -20,7 +20,12 @@ Command="{Binding ExitCommand}" /> - + + + +