[Agate-svn-commit] SF.net SVN: agate:[1535] trunk
Status: Alpha
Brought to you by:
kanato
From: <ka...@us...> - 2014-10-11 00:30:38
|
Revision: 1535 http://sourceforge.net/p/agate/code/1535 Author: kanato Date: 2014-10-11 00:30:23 +0000 (Sat, 11 Oct 2014) Log Message: ----------- Add writing files functionality. Modified Paths: -------------- trunk/AgateLib/Diagnostics/Log.cs trunk/AgateLib/IO/IReadWriteFileProvider.cs trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs Modified: trunk/AgateLib/Diagnostics/Log.cs =================================================================== --- trunk/AgateLib/Diagnostics/Log.cs 2014-10-11 00:24:39 UTC (rev 1534) +++ trunk/AgateLib/Diagnostics/Log.cs 2014-10-11 00:30:23 UTC (rev 1535) @@ -34,5 +34,13 @@ { Debug.WriteLine(format, args); } + + public static void Indent() + { + } + + public static void Unindent() + { + } } } Modified: trunk/AgateLib/IO/IReadWriteFileProvider.cs =================================================================== --- trunk/AgateLib/IO/IReadWriteFileProvider.cs 2014-10-11 00:24:39 UTC (rev 1534) +++ trunk/AgateLib/IO/IReadWriteFileProvider.cs 2014-10-11 00:30:23 UTC (rev 1535) @@ -18,12 +18,17 @@ // using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; namespace AgateLib.IO { public interface IReadWriteFileProvider : IReadFileProvider, IWriteFileProvider { + Task<Stream> OpenWriteAsync(string file); + + void CreateDirectory(string folder); } } Modified: trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs 2014-10-11 00:24:39 UTC (rev 1534) +++ trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs 2014-10-11 00:30:23 UTC (rev 1535) @@ -30,7 +30,7 @@ /// FileSystemProvider implements IFileProvider, providing access to files /// from the operating system file system. /// </summary> - public class FileSystemProvider : IReadFileProvider + public class FileSystemProvider : IReadWriteFileProvider { string mPath; Uri mPathUri; @@ -66,7 +66,7 @@ throw new FileNotFoundException(string.Format("The file {0} was not found in the path {1}.", filename, mPath)); - return File.OpenRead(FindFileName(filename)); + return await Task.Run(() => File.OpenRead(FindFileName(filename))); } /// <summary> /// Returns true if the specified file exists. @@ -290,5 +290,18 @@ { get { return true; } } + + public async Task<Stream> OpenWriteAsync(string file) + { + string resolvedName = FindFileName(file); + + return await Task.Run(() => File.Open(resolvedName, FileMode.Create)); + } + + public void CreateDirectory(string folder) + { + DebugCrossPlatform(folder); + Directory.CreateDirectory(Path.Combine(mPath, folder)); + } } } Modified: trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs 2014-10-11 00:24:39 UTC (rev 1534) +++ trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs 2014-10-11 00:30:23 UTC (rev 1535) @@ -1,8 +1,11 @@ using AgateLib.ApplicationModels; +using AgateLib.IO; using AgateLib.Platform.WinForms.ApplicationModels; using AgateLib.Platform.WinForms.Factories; using AgateLib.Platform.WinForms.IO; using AgateLib.Utility; +using System; +using System.IO; namespace AgateLib.Platform.WinForms { @@ -21,6 +24,10 @@ factory.SetAssetLocations(parameters.AssetLocations); Core.InitAssetLocations(parameters.AssetLocations); + var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + + FileProvider.UserFiles = new FileSystemProvider(Path.Combine(appData, parameters.ApplicationName)); + ////var assetProvider = new FileSystemProvider(System.IO.Path.GetFullPath(parameters.AssetLocations.Path)); ////AgateLib.IO.FileProvider.Initialize(assetProvider, parameters.AssetLocations); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |