Skip to content

Commit

Permalink
Remove duplicated namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes committed Apr 11, 2024
1 parent 7a677d0 commit 3097d2c
Showing 1 changed file with 74 additions and 77 deletions.
151 changes: 74 additions & 77 deletions System.IO.FileSystem/FileSystemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,108 +9,105 @@

namespace System.IO
{
namespace System.IO
/// <summary>
/// Provides the base class for both <see cref="FileInfo"/> and <see cref="DirectoryInfo"/> objects.
/// </summary>
public abstract class FileSystemInfo : MarshalByRefObject
{
internal NativeFileInfo _nativeFileInfo;

// fully qualified path of the directory
internal string _fullPath;

/// <summary>
/// Provides the base class for both <see cref="FileInfo"/> and <see cref="DirectoryInfo"/> objects.
/// Gets or sets the attributes for the current file or directory.
/// </summary>
public abstract class FileSystemInfo : MarshalByRefObject
public FileAttributes Attributes
{
internal NativeFileInfo _nativeFileInfo;

// fully qualified path of the directory
internal string _fullPath;

/// <summary>
/// Gets or sets the attributes for the current file or directory.
/// </summary>
public FileAttributes Attributes
get
{
get
{
RefreshIfNull();
RefreshIfNull();

return (FileAttributes)_nativeFileInfo.Attributes;
}
return (FileAttributes)_nativeFileInfo.Attributes;
}
}

/// <summary>
/// Gets the full path of the directory or file.
/// </summary>
public virtual string FullName
/// <summary>
/// Gets the full path of the directory or file.
/// </summary>
public virtual string FullName
{
get
{
get
{
return _fullPath;
}
return _fullPath;
}
}

/// <summary>
/// Gets the extension part of the file name, including the leading dot <code>.</code> even if it is the entire file name, or an empty string if no extension is present.
/// </summary>
/// <value>A string containing the FileSystemInfo extension.</value>
public string Extension
/// <summary>
/// Gets the extension part of the file name, including the leading dot <code>.</code> even if it is the entire file name, or an empty string if no extension is present.
/// </summary>
/// <value>A string containing the FileSystemInfo extension.</value>
public string Extension
{
get
{
get
{
return Path.GetExtension(FullName);
}
return Path.GetExtension(FullName);
}
}

/// <summary>
/// Gets a value indicating whether the file or directory exists.
/// </summary>
public abstract bool Exists
{
get;
}
/// <summary>
/// Gets a value indicating whether the file or directory exists.
/// </summary>
public abstract bool Exists
{
get;
}

/// <summary>
/// Gets the name of the file.
/// </summary>
public abstract string Name
{
get;
}
/// <summary>
/// Gets the name of the file.
/// </summary>
public abstract string Name
{
get;
}

/// <summary>
/// Deletes a file or directory.
/// </summary>
public abstract void Delete();
/// <summary>
/// Deletes a file or directory.
/// </summary>
public abstract void Delete();

/// <summary>
/// Refreshes the state of the object.
/// </summary>
/// <exception cref="IOException">A device such as a disk drive is not ready.</exception>
public void Refresh()
/// <summary>
/// Refreshes the state of the object.
/// </summary>
/// <exception cref="IOException">A device such as a disk drive is not ready.</exception>
public void Refresh()
{
object record = FileSystemManager.AddToOpenListForRead(_fullPath);

try
{
object record = FileSystemManager.AddToOpenListForRead(_fullPath);
_nativeFileInfo = NativeFindFile.GetFileInfo(_fullPath);

try
if (_nativeFileInfo == null)
{
_nativeFileInfo = NativeFindFile.GetFileInfo(_fullPath);
IOException.IOExceptionErrorCode errorCode = (this is FileInfo) ? IOException.IOExceptionErrorCode.FileNotFound : IOException.IOExceptionErrorCode.DirectoryNotFound;

if (_nativeFileInfo == null)
{
IOException.IOExceptionErrorCode errorCode = (this is FileInfo) ? IOException.IOExceptionErrorCode.FileNotFound : IOException.IOExceptionErrorCode.DirectoryNotFound;

throw new IOException(
string.Empty,
(int)errorCode);
}
}
finally
{
FileSystemManager.RemoveFromOpenList(record);
throw new IOException(
string.Empty,
(int)errorCode);
}
}
finally
{
FileSystemManager.RemoveFromOpenList(record);
}
}

internal void RefreshIfNull()
internal void RefreshIfNull()
{
if (_nativeFileInfo == null)
{
if (_nativeFileInfo == null)
{
Refresh();
}
Refresh();
}
}
}
Expand Down

0 comments on commit 3097d2c

Please sign in to comment.