Commit Graph
119 Commits
Author SHA1 Message Date
Miguel de Icaza d518bd927a [corlib] Remove stale comments 2014-05-04 17:34:12 -04:00
Andrés G. Aragoneses 0eb40ad2da Fix very sticky typo in numerous places 2014-01-19 17:51:24 +01:00
Rodrigo Kumpera d6fd0cde05 Make sure the behavior between GetFiles and EnumerateFiles are the same regarding symlinks. Fixes BXC #12461
* Directory.cs: Only ignore symlinks when traversing subdirectories. This is the only case that it can result
	in loops.
2013-06-04 18:49:34 -04:00
Rodrigo Kumpera 1b92a4148c Since MOBILE implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:42:18 -05:00
Rodrigo Kumpera b96d05dac3 Kill the MOONLIGHT define in corlib. 2013-02-11 16:03:28 -05:00
Peter Collingbourne b7141524e4 Rewrite implementation of Directory.EnumerateKind
This rewrite fixes three bugs:

 1) Fixes the case where AllDirectories is specified and searchPattern
    is anything other than '*'.  Now, every directory is searched
    recursively, not just those which match the pattern.

 2) Fully solves the issue that commit e09e64b tried to fix.  Now
    the check for hidden files occurs for every file, rather than
    only the first.

 3) Error handling is now performed at calls to both FindFirst and
    FindNext, not just FindFirst.
2012-09-14 03:02:22 +01:00
Nican 05f783b50f Fixed incorrect line spacing 2012-08-15 01:35:03 -04:00
Nican 74a9f9b133 When enabling security with "mono_security_enable_core_clr" on a Windows machine, it causes an infinite recession when calling System.IO.Directory.GetCurrentDirectory.
The loop is happening between these calls:
https://github.com/mono/mono/blob/92d8961e0b244429d4d82176f4b33c8a4b3b064c/mcs/class/corlib/System.IO/Path.cs#L298
https://github.com/mono/mono/blob/3c39ac4586b4470703fb4af0208b5baf1de70e43/mcs/class/corlib/System.Security.Permissions/FileIOPermission.cs#L157
https://github.com/mono/mono/blob/9322e0d16b0edc054947279af34d3c7afb286c89/mcs/class/corlib/System.IO/Directory.cs#L248

Stack trace as follows:

The requested operation caused a stack overflow.  at (wrapper managed-to-native) System.IO.MonoIO:GetCurrentDirectory (System.IO.MonoIOError&)
  at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
  at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
  at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission.AddPathInternal (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission.AddPathList (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission..ctor (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
  at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
  at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission.AddPathInternal (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission.AddPathList (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.Security.Permissions.FileIOPermission..ctor (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
  at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
  at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
  at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
...Snip...
2012-08-15 01:31:09 -04:00
James Bellinger 9322e0d16b ACLs now work on Windows. Tests all the way up to DirectorySecurityTest and FileSecurityTest.
NativeObjectSecurity is implemented.
I've done it in such a way that, for OSes that do not have a unified API for all ACLs,
overrides can be done in subclasses such as FileSystemSecurity without trouble.

ObjectSecurity, CommonObjectSecurity, and DirectoryObjectSecurity all implemented.
MutexSecurity, PipeSecurity, etc. all just add type specialization and nothing else. Implemented all of these as well.

Access and Audit rules now correctly use NTAccount in their string overloads (see unit tests).
The constructors all provide correct AccessMasks now. In other words, these classes are all now un-broken/no longer stubs.

More unit tests for CommonSecurityDescriptor and fixes to pass them.
A few had checks that were redundant (implemented by (Authorization|Audit|Access)Rule) as well. These have been removed.
The Allow Everyone Full Access default for null DiscretionaryAcls in CommonSecurityDescriptor is, I think,
properly implemented. This required some changes to GenericSecurityDescriptor as well, but now Mono matches
MS.NET on GetSddl/GetBinaryForm for null DiscretionaryAcl including roundtrip.

What's still missing:
(1) CommonAcl's RemoveAccess/RemoveAudit. RemoveAll and RemoveSpecific work so it's not a big issue.
(2) CommonAcl merging will not yet try to merge a CommonAce together with an ObjectAce.
(3) The various *Security constructors. Get/SetAccessControl work on files and directories.
However, you still have to create and then set. I am not too familiar with Mono runtime internal
calls, but to someone who is: If the SECURITY_ATTRIBUTES parameter to Create*'s lpSecurityDescriptor
pointed to the output of GenericSecurityDescriptor's GetBinaryForm, that would be a complete
implementation.
2012-07-07 18:45:06 -04:00
Marek Safar e09e64bead Try to fix Directory.EnumerateFiles for hidden files 2012-06-15 16:04:08 +01:00
Marek Habersack 09a73ad0d1 [corlib] Correctly recurse directories in Directory.EnumerateFiles if the first entry is a directory
If the first entry in a directory happened to be another directory, the code wouldn't descend if
SearchOption.AllDirectoris was specified.
2012-04-06 19:35:38 +02:00
Sebastien Pouliot e7194f9a11 another case where the linker needs help to eliminate CAS 2011-07-20 11:39:48 -04:00
Marek Habersack b0ba50443f [runtime,IO] Filesystem entries can only be sought for in directories, not files. 2011-04-13 16:56:37 +02:00
Gonzalo Paniagua Javier 2b618c8045 Revert "Fix a typo in Directory.GetFiles ()"
This reverts commit 5bbd6c23f8.
2011-03-30 20:23:14 -04:00
Gonzalo Paniagua Javier 073de8e603 Fix a typo in Directory.GetFiles ()
The mask never matched the attributes and all files were discarded.
	This fixes bug #683203.
2011-03-28 17:47:41 -04:00
Geoff Norton 16d4fd790b Further .NET 4.0 ification of the mobile profile 2011-01-25 20:10:54 -05:00
Zoltan Varga 9899a5f249 Change some usages of ArrayList to List<T> to avoid calls to the slow ArrayList.ToArray(Type) method. 2011-01-06 13:11:56 +01:00
Gonzalo Paniagua Javier 45db947ccc 2010-05-27 William Holmes <[email protected]>
* Directory.cs (ValidateDirectoryListing): Removing an unnecessary
	Path.Combine call. Part of the fix for bug #580090.

	Code is contributed under MIT/X11 license.


svn path=/trunk/mcs/; revision=159860
2010-07-04 16:41:33 +00:00
Sebastien Pouliot e6fd69e444 2010-04-16 Sebastien Pouliot <[email protected]>
* Directory.cs: Ensure elevated trust when calling on 
	Moonlight.
	* DirectoryInfo.cs: Ensure elevated trust when calling a .ctor 
	on Moonlight.
	* File.cs: Ensure elevated trust when calling a .ctor on 
	Moonlight.
	* FileInfo.cs: Ensure elevated trust when calling a .ctor on 
	Moonlight.
	* FileStream.cs: Ensure elevated trust when calling a .ctor on 
	Moonlight. Name property returns "[Unknown]" unless a Moonlight
	application is executed with elevated trust.
	* Path.cs: Ensure elevated trust when calling a GetTempPath,
	GetTempFileName or GetFullPath on Moonlight. Add a shared 
	internal method to validate paths to reduce code duplication.


svn path=/trunk/mcs/; revision=155643
2010-04-16 17:29:07 +00:00
Jb Evain 69519131eb 2010-04-15 Jb Evain <[email protected]>
* Directory.cs: don't fully qualify name when not it's necessary.


svn path=/trunk/mcs/; revision=155497
2010-04-15 11:56:06 +00:00
Gonzalo Paniagua Javier 51f4b1ce2d 2010-03-25 Gonzalo Paniagua Javier <[email protected]>
* Directory.cs: a directory named ":" is legal in unix.
	This gets rid of the annoying ":" folder when running
	corlib tests.


svn path=/trunk/mcs/; revision=154189
2010-03-25 05:39:05 +00:00
Sebastien Pouliot 5012b755ff 2010-03-22 Sebastien Pouliot <[email protected]>
* Directory.cs, DirectoryInfo.cs: Disble new NET_4_0 API used in
	SL4 until we have elevated trust working correctly (since they 
	are *not* decorated as [SecurityCritical])


svn path=/trunk/mcs/; revision=153968
2010-03-22 11:53:14 +00:00
Jb Evain 05a5b21fa0 use MOONLIGHT symbol
svn path=/trunk/mcs/; revision=153656
2010-03-16 12:10:19 +00:00
Rolf Bjarne Kvinge f66b3edf96 2010-03-16 Rolf Bjarne Kvinge <[email protected]>
* Path.cs:
	* Directory.cs:
	* DirectoryInfo.cs: Add some of the 4.0 methods to Moonlight.

svn path=/trunk/mcs/; revision=153650
2010-03-16 10:47:36 +00:00
Jeffrey Stedfast eef0c25e26 fix grammar in an exception
svn path=/trunk/mcs/; revision=152749
2010-03-01 20:59:37 +00:00
Zoltan Varga aa4d0babe2 2010-01-31 Zoltan Varga <[email protected]>
* Directory.cs (Exists): Never throw an exception. Fixes #565152.

svn path=/trunk/mcs/; revision=150605
2010-01-31 19:17:34 +00:00
Miguel de Icaza 285e89d96a Add new overloads
svn path=/trunk/mcs/; revision=146707
2009-11-23 07:22:20 +00:00
Miguel de Icaza 4ca87b5d71 2009-11-23 Miguel de Icaza <[email protected]>
* Directory.cs: Add EnumerateFiles and EnumerateFileSystemEntries
	overloads.    Share code.

svn path=/trunk/mcs/; revision=146706
2009-11-23 06:51:41 +00:00
Miguel de Icaza 957a0f21d3 2009-11-22 Miguel de Icaza <[email protected]>
* Directory.cs: Added new IEnumerable methods to Directory.

	* MonoIO.cs: Surface a high level FindFirst/FindNext API to
	implement the various enumerable APIs.

svn path=/trunk/mcs/; revision=146698
2009-11-23 03:44:51 +00:00
Geoff Norton 32555b5234 restore some types to MT
svn path=/trunk/mcs/; revision=144324
2009-10-18 16:55:11 +00:00
Miguel de Icaza 0204abe803 Drop more obsolete defines
svn path=/trunk/mcs/; revision=144304
2009-10-17 01:35:27 +00:00
Sebastien Pouliot ada00d32ed 2009-09-23 Sebastien Pouliot <[email protected]>
* Directory.cs: Don't expose SearchOption in NET_2_1
	* DirectoryInfo.cs: Don't expose SearchOption in NET_2_1
	* MonoIO.cs: Don't throw a DriveNotFoundException under NET_2_1 -
	an IOExpection will be thrown (like the 1.x profile)


svn path=/trunk/mcs/; revision=142479
2009-09-23 12:41:59 +00:00
Sebastien Pouliot 2203a2bb29 2009-09-18 Sebastien Pouliot <[email protected]>
* Directory.cs: Avoid imperative CAS checks and remove 
	AccessControl types for NET_2_1
	* DirectoryInfo.cs: Remove AccessControl types for NET_2_1
	* File.cs: Remove AccessControl types for NET_2_1
	* FileInfo.cs: Remove AccessControl types for NET_2_1
	* FileStream.cs: Remove AccessControl types for NET_2_1
	* Path.cs: Avoid imperative CAS checks for NET_2_1


svn path=/trunk/mcs/; revision=142197
2009-09-18 15:57:32 +00:00
Andreas N b7ebfaf624 2008-07-03 Andreas Nahr <[email protected]>
* TextWriter.cs:
	* StreamWriter.cs:
	* StreamReader.cs:
	* Stream.cs:
	* MemoryStream.cs:
	* File.cs:
	* DriveNotFoundException.cs:
	* Directory.cs: Fix parameter names

svn path=/trunk/mcs/; revision=107182
2008-07-03 20:00:51 +00:00
Andreas N 3df89d4a6d 2008-06-30 Andreas Nahr <[email protected]>
* BinaryReader.cs: Fix parameter names
	* BinaryWriter.cs: Fix parameter names, fix exceptions
	* BufferedStream.cs: Fix parameter names
	* Directory.cs: Fix parameter names, fix exceptions, optimize == "" cases
	* DirectoryInfo.cs:
	* DirectoryNotFoundException.cs:
	* FileNotFoundException.cs:
	* FileStream.cs: Fix parameter names, fix exceptions
	* IOException.cs: Fix parameter names

svn path=/trunk/mcs/; revision=106943
2008-06-30 23:02:31 +00:00
Gert Driesen 5d4e8d2ce4 * DirectoryInfo.cs: Added new internal ctor, which takes a bool that
indicates whether the original path should only container the last
part of the directory. Moved logic for determining the Name and
Parent to Initialize method, to allow it to be re-used on
deserialization. Renamed argument names to fix corcompare issues.
Added missing argument checks.
* Directory.cs (CreateDirectoriesInternal): Use internal ctor for
DirectoryInfo to ensure OriginalPath only contains last part of
the directory.
* File.cs: Removed redundant checks from Create. On 2.0 profile, pass
FileOptions to FileStream. Removed redundant directory check from
Delete and modified exceptions to more closely match MS.
* FileInfo.cs: Added argument check to ctor to match MS. Added missing
deserialization ctor. Modified argument checks in MoveTo, and removed
redundant checks. Added missing argument checks in CopyTo. Code
formatting.
* FileSystemInfo.cs: Modified argument checks in CheckPath to more
closely match MS.
* MonoIO.cs: Added msg that does not disclose filename for
ERROR_FILE_EXISTS.
* Path.cs: Use String.Length instead of comparing with String.Empty.
Removed exceptions argument names to match MS.
* File.cs: Added/improved tests for Create and Move.
* DirectoryInfoTest.cs: No longer derive from deprecated Assertion
class. Improved tests for ctor, Create, Name, Parent, ...
* FileInfoTest.cs: No longer derive from deprecated Assertion class.
Improved/added tests, 
* PathTest.cs: Added tests for IsPathRooted and GetFullPath.
* FileSystemInfoTest.cs: Fixed test. Now passes on both Mono and MS.

svn path=/trunk/mcs/; revision=101006
2008-04-17 15:04:25 +00:00
Sebastien Pouliot d01e58912f 2008-03-28 Sebastien Pouliot <[email protected]>
* Directory.cs: Exception differs when deleting a directory if it 
	does not exists or if a file of the same name exists. Also don't 
	include path in exception if Delete fails.


svn path=/trunk/mcs/; revision=99230
2008-03-28 19:07:33 +00:00
Gert Driesen f21385dd39 * Directory.cs: Renamed Move arguments to match MS. Allow Move to be
used to move files, patch by Robert Jordan. Fixes bug #81912. Spaces
to tabs.
* DirectoryCas.cs: Changed Move to MoveDirectory to match the
method in DirectoryTest. Fixed line endings.
* DirectoryTest.cs: Added test for bug #81912. Added tests for Move
argument checks.

svn path=/trunk/mcs/; revision=81599
2007-07-08 15:56:55 +00:00
Dick Porter 5b79519900 2007-04-30 Dick Porter <[email protected]>
* Directory.cs: 
	* FileShare.cs: 
	* DirectoryNotFoundException.cs: 
	* SeekOrigin.cs: 
	* FileAttributes.cs: 
	* IOException.cs: 
	* MemoryStream.cs: 
	* FileMode.cs: 
	* BinaryWriter.cs: 
	* TextWriter.cs: 
	* File.cs: 
	* BinaryReader.cs: 
	* TextReader.cs: 
	* UnmanagedMemoryStream.cs: 
	* StringWriter.cs: 
	* FileAccess.cs: 
	* FileLoadException.cs: 
	* BufferedStream.cs: 
	* Stream.cs: 
	* FileInfo.cs: 
	* FileStream.cs:
	* StringReader.cs: 
	* StreamWriter.cs: 
	* EndOfStreamException.cs: 
	* DriveInfo.cs: 
	* StreamReader.cs: 
	* PathTooLongException.cs: 
	* DriveType.cs: 
	* FileNotFoundException.cs: 2.0 profile updates



svn path=/trunk/mcs/; revision=76495
2007-04-30 14:05:12 +00:00
Dick Porter 37bc149b80 Reinstate this change.
2007-04-05  Dick Porter  <[email protected]>

	* Directory.cs: Pass combined path and pattern to
	MonoIO.GetFileSystemEntries()



svn path=/trunk/mcs/; revision=76250
2007-04-25 13:53:05 +00:00
Dick Porter d162abe1b3 Revert this while I figure out why monodevelop breaks
svn path=/trunk/mcs/; revision=75777
2007-04-16 17:02:22 +00:00
Dick Porter acacb61e04 2007-04-05 Dick Porter <[email protected]>
* Directory.cs: Pass combined path and pattern to
	MonoIO.GetFileSystemEntries()

2007-04-05  Dick Porter  <[email protected]>

	* Environment.cs: Increment mono_corlib_version



svn path=/trunk/mcs/; revision=75432
2007-04-05 12:43:26 +00:00
Alp Toker d7dc652806 2007-03-18 Alp Toker <[email protected]>
* UnmanagedMemoryStream.cs:
	* Directory.cs: Exception message typo fixes.


svn path=/trunk/mcs/; revision=74573
2007-03-18 22:04:17 +00:00
Eyal Alalouf fbd34a95a9 Use MonoNotSupported & MonoLimitation attribute to tag that DirectorySecurity is not supported.
svn path=/trunk/mcs/; revision=73302
2007-02-22 10:25:25 +00:00
Miguel de Icaza 3a23274a17 Revert Patch 72756 until we review and discuss this publicly
svn path=/trunk/mcs/; revision=72768
2007-02-13 13:07:41 +00:00
Miguel de Icaza 0c4de17e04 Revert this part: empty strings are valid names in Unix
svn path=/trunk/mcs/; revision=72767
2007-02-13 13:00:31 +00:00
Boris Kirzner 04052b1827 Path handling fixes in File, Directory and Path including windows-specific negative flows.
svn path=/trunk/mcs/; revision=72756
2007-02-13 12:04:32 +00:00
Alp Toker dfc3ae9bf9 2006-12-23 Alp Toker <[email protected]>
* Directory.cs: "platfor" typofix


svn path=/trunk/mcs/; revision=70005
2006-12-23 23:58:19 +00:00
Atsushi Eno ed62a988d2 2006-12-22 Atsushi Enomoto <[email protected]>
* Directory.cs : non NET_2_0 build fix.


svn path=/trunk/mcs/; revision=69926
2006-12-22 09:26:33 +00:00
Miguel de Icaza 8e98d66d5f CorCompare work
svn path=/trunk/mcs/; revision=69918
2006-12-22 00:53:15 +00:00