Skip to content

Commit

Permalink
WindowsStore/WindowsPhone: More work on MPfm.Library; a new implement…
Browse files Browse the repository at this point in the history
…ation of ISQLiteGateway is in progress for WinRT.

Related to issue #423 and issue #424.
  • Loading branch information
ycastonguay committed Sep 3, 2013
1 parent 4532ad8 commit d6dbbaf
Show file tree
Hide file tree
Showing 10 changed files with 2,077 additions and 1,287 deletions.
43 changes: 43 additions & 0 deletions MPfm/MPfm.Core/Helpers/FileHelper.cs
@@ -0,0 +1,43 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.IO;
using System.Threading.Tasks;
using MPfm.Core.WinRT;
#if WINDOWSSTORE
using Windows.Storage;
#endif

namespace MPfm.Core.Helpers
{
public static class FileHelper
{
public static bool FileExists(string filePath)
{
#if WINDOWSSTORE
//bool exists = await ApplicationData.Current.LocalFolder.FileExistsAsync(filePath);
var task = ApplicationData.Current.LocalFolder.FileExistsAsync(filePath);
//task.RunSynchronously();
//return exists;
return true;
#else
return File.Exists(filePath);
#endif
}
}
}
2 changes: 2 additions & 0 deletions MPfm/MPfm.Core/MPfm.Core.WindowsStore.csproj
Expand Up @@ -108,6 +108,7 @@
<Compile Include="CacheStore.cs" />
<Compile Include="Conversion.cs" />
<Compile Include="DatabaseFieldNameAttribute.cs" />
<Compile Include="Helpers\FileHelper.cs" />
<Compile Include="Normalizer.cs" />
<Compile Include="OS.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -117,6 +118,7 @@
<Compile Include="Helpers\XMLHelper.cs" />
<Compile Include="Network\IPAddressRangeFinder.cs" />
<Compile Include="Network\WebClientTimeout.cs" />
<Compile Include="WinRT\ExtensionMethods.cs" />
<Compile Include="XmlSerialization.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
37 changes: 37 additions & 0 deletions MPfm/MPfm.Core/WinRT/ExtensionMethods.cs
@@ -0,0 +1,37 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;

namespace MPfm.Core.WinRT
{
public static class ExtensionMethods
{
public async static Task<bool> FileExistsAsync(this StorageFolder folder, string name)
{
var files = await folder.GetFilesAsync();

return files.Any((f) => {
return f.Name == name;
});
}
}
}

0 comments on commit d6dbbaf

Please sign in to comment.