Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on StorageFolder and StorageFile #23

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions source/Windows.Storage/FileAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public enum FileAttributes
/// The item is a directory.
/// </summary>
Directory = 16,
///// <summary>
///// The item is locally incomplete. Windows only.
///// </summary>
//LocallyIncomplete = 512,

/// <summary>
/// The item is locally incomplete. Windows only.
/// </summary>
LocallyIncomplete = 512,

/// <summary>
/// The item is normal. That is, the item doesn't have any of the other values in the enumeration.
Expand All @@ -35,10 +35,10 @@ public enum FileAttributes
/// The item is read-only.
/// </summary>
ReadOnly = 1,
///// <summary>
///// The item is a temporary file.
///// </summary>
//Temporary = 256

/// <summary>
/// The item is a temporary file.
/// </summary>
Temporary = 256
}
}
65 changes: 65 additions & 0 deletions source/Windows.Storage/Search/CommonFileQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// Copyright (c) 2019 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.
//

namespace Windows.Storage.Search
{
/// <summary>
/// Specifies how to sort the files in the query results and determines whether the query is shallow or deep. Query results for deep queries include all files in all of the subfolders of the current folder, sorted according to the specified option.
/// </summary>
public enum CommonFileQuery
{
/// <summary>
/// A shallow list of files in the current folder, similar to the list that File Explorer provides.
/// You can use this option for any storage location.
/// </summary>
DefaultQuery,

/// <summary>
/// A deep, flat list of files in a folder and its subfolders, sorted by System.ItemNameDisplay.
/// You can use this option for any storage location.
/// </summary>
///<remarks>
/// This method is not available in nanoFramework.
///</remarks>
OrderByName,

/// <summary>
/// A deep, flat list of files in a folder and its subfolders, sorted by System.Title.
/// You can use this option only for folders in a library or the HomeGroup folder.
/// </summary>
///<remarks>
/// This method is not available in nanoFramework.
///</remarks>
OrderByTitle,

/// <summary>
/// A deep, flat list of files in a folder and its subfolders, sorted by music properties.
/// You can use this option only for folders in a library or the HomeGroup folder.
/// </summary>
///<remarks>
/// This method is not available in nanoFramework.
///</remarks>
OrderByMusicProperties,

/// <summary>
/// A deep, flat list of files in a folder and its subfolders, sorted by System.Search.Rank followed by System.DateModified.
/// You can use this option for any storage location.
/// </summary>
///<remarks>
/// This method is not available in nanoFramework.
///</remarks>
OrderBySearchRank,

/// <summary>
/// A deep, flat list of files in a folder and its subfolders, sorted by System.ItemDate.
/// You can use this option only for folders in a library or the HomeGroup folder.
/// </summary>
///<remarks>
/// This method is not available in nanoFramework.
///</remarks>
OrderByDate
}
}
93 changes: 83 additions & 10 deletions source/Windows.Storage/StorageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See LICENSE file in the project root for full license information.
//


using System;

namespace Windows.Storage
Expand All @@ -12,37 +13,109 @@ namespace Windows.Storage
/// </summary>
public sealed class StorageFile : IStorageFile//, IStorageFile2, IStorageFilePropertiesWithAvailability, IStorageItem, IStorageItem2, IStorageItemProperties, IStorageItemProperties2, IStorageItemPropertiesWithProvider, IInputStreamReference, IRandomAccessStreamReference
{
#region backing and internal fields

#pragma warning disable 0649

// this field is set in native code
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private readonly DateTime _dateCreated;

private string _contentType;
private string _fileType;
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private string _name;

[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private string _path;

// public FileAttributes Attributes { get; }
#pragma warning restore 0649

#endregion

/// <summary>
/// Gets the attributes of a file.
/// </summary>
/// <value>
/// The file attributes.
/// </value>
public FileAttributes Attributes => FileAttributes.Normal;

/// <summary>
/// Gets the MIME type of the contents of the file.
/// </summary>
public string ContentType => _contentType;
///<remarks>
/// This property is not available in nanoFramework.
///</remarks>
public string ContentType => "";

// public DateTimeOffset DateCreated { get; }
/// <summary>
/// Gets the date and time that the current folder was created.
/// </summary>
/// <remarks>
/// This is the nanoFrameowrk equivalent of UWP DateCreated of type DateTimeOffset.
/// </remarks>
public DateTime DateCreated => _dateCreated;

// public string DisplayName { get; }
/// <summary>
/// Gets the user-friendly name of the current folder.
/// </summary>
///<remarks>
/// This property is not available in nanoFramework.
///</remarks>
public string DisplayName => "";

// public string DisplayType { get; }
/// <summary>
/// Gets the user-friendly description of the type of the folder; for example, JPEG image.
/// </summary>
///<remarks>
/// This property is not available in nanoFramework.
///</remarks>
public string DisplayType => "";

/// <summary>
/// Gets the type (file name extension) of the file.
/// </summary>
public string FileType => _fileType;
public string FileType
{
get
{
if(_name != null)
{
var dotIndex = _name.LastIndexOf('.');

return _name.Substring(dotIndex + 1, _name.Length - dotIndex - 1);
}
else
{
return "";
}
}
}

// public string FolderRelativeId { get; }
/// <summary>
/// Gets an identifier for the file. This ID is unique for the query result or <see cref="StorageFolder"/> that contains the file and can be used to distinguish between items that have the same name.
/// </summary>
///<remarks>
/// This property is not available in nanoFramework.
///</remarks>
public string FolderRelativeId => "";

// public bool IsAvailable { get; }
/// <summary>
/// Indicates if the file is local, is cached locally, or can be downloaded.
/// </summary>
/// <value>
/// True if the file is local, is cached locally, or can be downloaded. Otherwise, false.
/// </value>
///<remarks>
/// This property is always true in nanoFramework.
///</remarks>
public bool IsAvailable => true;

/// <summary>
/// Gets the name of the file including the file name extension.
/// </summary>
/// <value>
/// The name of the file including the file name extension.
/// </value>
public string Name => _name;

/// <summary>
Expand Down
Loading