Commit Graph
104 Commits
Author SHA1 Message Date
Marek Safar b184bbea53 [corlib] Remove heavyweight EndsWith from 1bff9d890f 2014-08-12 08:49:29 +02:00
João Matos 1bff9d890f Fixed Path.GetFullPath to work correctly when the current path is '/'.
Fixes xambug #833.
2014-08-08 19:03:39 +01:00
Marek Safar fc5f457120 [corlib] Use invariant culture for GetTempFileName generator 2014-05-08 10:26:29 +02:00
Miguel de Icaza 040ba8b7e8 [mscorlib] Path: fix GetFullPath (/../bin/bash) to return /bin/bash, not bin/bash, fixes 17083 2014-02-12 13:19:31 -05:00
Marek Safar 5a20d0438a [corlib] Path.Combine with variable arguments length where one is empty should give same result as other Combine overloads 2014-02-05 16:56:03 +01:00
Miguel de Icaza a52849e336 Fix inacurrate reference 2013-10-04 15:39:09 -04:00
TalAloni 155a4799fc Fix for bug 12892 - Path.GetFullPath() may return incorrect relative path under Windows 2013-06-28 11:25:54 +03:00
Jonathan Pryor b1f4d6dfcc [corlib] Don't throw UnauthorizedAccessException from Path.GetTempFileName
The problem is sporadic mdoc test failures on Wrench/OS X:

	Updating: Mono.DocTest.Widget/NestedClass/Double/Triple/Quadruple
	mdoc: System.UnauthorizedAccessException: Access to the path '/var/folders/_g/y9v720_90l914yylrk7m903c0000gn/T/tmp20f71445.tmp' is denied.
	  at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
	  at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,bool,System.IO.FileOptions)
	  at System.IO.Path.GetTempFileName () [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MdocFile.UpdateFile (System.String file, System.Action`1 creator) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.WriteFile (System.String filename, FileMode mode, System.Action`1 action) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.DoUpdateType2 (System.String message, System.Xml.XmlDocument basefile, Mono.Cecil.TypeDefinition type, System.String output, Boolean insertSince) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.DoUpdateType (Mono.Cecil.TypeDefinition type, System.String basepath, System.String dest) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.DoUpdateAssembly (Mono.Cecil.AssemblyDefinition assembly, System.Xml.XmlElement index_types, System.String source, System.String dest, System.Collections.Generic.HashSet`1 goodfiles) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.DoUpdateAssemblies (System.String source, System.String dest) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDocUpdater.Run (IEnumerable`1 args) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDoc.Run (System.String[] args) [0x00000] in <filename unknown>:0
	  at Mono.Documentation.MDoc.Main (System.String[] args) [0x00000] in <filename unknown>:0

I'm not sure why we're getting UnauthorizedAccessException exceptions,
nor do I particularly care; Path.GetTempFileName() should not be
throwing UnauthorizedAccessException; only IOException is documented:

	http://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename.aspx

Update behavior to skip files that generate
UnauthorizedAccessException, and if we swallow short.MaxValue
exceptions wrap the UnauthorizedAccessException in an IOException so
that we conform to documented exceptional behavior.
2013-06-03 16:57:31 -04:00
Marek Safar 6c083808ce Use faster/smaller versions for some string comparisons 2013-03-02 18:56:31 +01:00
Rodrigo Kumpera abe9dc6206 Revert "Fix object::GetType when remoting is enabled."
This reverts commit 93e2d1dc48.
2013-03-01 10:54:09 -05:00
Rodrigo Kumpera 93e2d1dc48 Fix object::GetType when remoting is enabled. 2013-03-01 10:52:03 -05:00
TalAloni 19baf6c162 Update Path.cs
Fixed Path.GetDirectoryName() bug when path is in the following form: 'C:filename'
2013-03-01 02:47:07 +02: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
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
Marek Safar 92d8961e0b Canonicalize path on windows. Fixes #4625 2012-04-26 16:17:19 +01:00
Miguel de Icaza 2852ed0b59 Update copyrights 2011-09-13 18:26:13 -04:00
Atsushi Eno 0a23442387 Fix invalid path check for Windows regarding ':'. 2011-08-31 14:10:43 -07:00
Alan McGovern 2c78755226 [System.IO.Path] Fix potential infinite loop in Path.GetTempFileName
Refactor this method so that it only attempts alternative filenames if
the filename just attempted already exists. This way we will never end
up looping forever being unable to create the required file. Previously
if we opened the maximum allowed files and then called GetTempFileName
we'd loop forever throwing an IOException in the FileStream constructor
every time.
2011-08-02 17:54:39 +01:00
Geoff Norton 16d4fd790b Further .NET 4.0 ification of the mobile profile 2011-01-25 20:10:54 -05:00
Miguel de Icaza d224fe524c [mscorlib] New Path.Combine methods are exposed internally on pre 4.0 profiles
This allows our mscorlib code to be cleaner
2011-01-03 08:50:53 -05:00
Marek Habersack 7312d09305 2010-05-20 Marek Habersack <[email protected]>
* FileStream.cs: when running on Windows and a path with Unix
	directory separator chars is passed (including an UNC share), get
	the canonical form of the path before attempting to retrieve its
	directory name. Fixes bug #607502

	* Path.cs: typo fix

svn path=/trunk/mcs/; revision=157650
2010-05-20 21:54:22 +00:00
Marek Habersack 5aa256010e 2010-05-08 Marek Habersack <[email protected]>
* Path.cs: vararg overload of Combine now correctly concatenates
	segments.
	The 3 and 4 argument overloads of Combine check whether the passed
	segments are null or not.

2010-05-08  Marek Habersack  <[email protected]>

	* PathTest.cs: added tests for the 4.0 Combine overloads.

svn path=/trunk/mcs/; revision=156928
2010-05-07 23:00:28 +00:00
Gonzalo Paniagua Javier ab075382d5 2010-05-05 Gonzalo Paniagua Javier <[email protected]>
* Path.cs: prevent infinite loop when TMPDIR (or equivalent)
	points to a non-existent directory.


svn path=/trunk/mcs/; revision=156704
2010-05-05 04:08:49 +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
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
Zoltan Varga cd6e00fab3 2010-03-11 Zoltan Varga <[email protected]>
* Path.cs (GetTempFileName): Fix infinite loop if the process doesn't have
	write access to /tmp. Fixes #585017.

svn path=/trunk/mcs/; revision=153433
2010-03-11 00:49:37 +00:00
Marek Safar 6bec77af06 2009-11-24 Marek Safar <[email protected]>
* StreamReader.cs, FileStream.cs: Use recycle buffer to avoid
	repeated underlying buffer initialization (saves hefty 10MB
	during corlib compilation).
	
	* Path.cs (InsecureGetFullPath): Avoid CanonicalizePath in common
	path.


svn path=/trunk/mcs/; revision=146841
2009-11-24 16:30:55 +00:00
Miguel de Icaza e9eafddcd6 2009-11-07 Miguel de Icaza <[email protected]>
* UnmanagedMemoryStream.cs: Move the CLS attribute to the methods
	that are unsafe.

	* Path.cs (Combine):e Fix implementation to follow docs (we need
	to reset the path if any of the combined paths is rooted), and add a
	couple of overloads;

	* FileStream.cs (Flush/flushToDisk): Implement.

	* Stream.cs (CopyTo): Implement.



svn path=/trunk/mcs/; revision=145640
2009-11-07 07:09:10 +00:00
Miguel de Icaza 53e7b9d5b6 2009-10-21 Miguel de Icaza <[email protected]>
* BinaryWriter.cs, BinaryReader.cs: 4.0 signature update.

	* File.cs (ReadLines, AppendAllLines, WriteAllLines): Add
	IEnumerable methods.

	* Path.cs (Combine): add the params overload. 

svn path=/trunk/mcs/; revision=144597
2009-10-22 03:19:06 +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 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
Gonzalo Paniagua Javier 5a1a456325 2009-07-14 Gonzalo Paniagua Javier <[email protected]>
* Path.cs: only trim the end of the file.
	Fixes bug #521924.

svn path=/trunk/mcs/; revision=137909
2009-07-15 00:25:06 +00:00
Gonzalo Paniagua Javier 01e2ec8f69 2008-10-29 Gonzalo Paniagua Javier <[email protected]>
* Path.cs: clean the path when we're not in windows. 
	Bug #321706 fixed.


svn path=/trunk/mcs/; revision=117435
2008-10-29 22:19:49 +00:00
Gert Driesen a9d44f8ddf * Path.cs: Fixed exception arguments to match MS. Removed obsolete
LAMESPEC comment. In GetPathRoot, throw ArgumentException if path
is whitespace-only. Throw ArgumentException in HasExtension, if path
contains invalid path characters.
* PathCas.cs: Updated method names to reflect changes in PathTest.
* PathTest.cs: Renamed tests. Use String.Empty instead of "". Added
argument check tests, and moved tests to separate methods. Avoid using 
ExpectedException.

svn path=/trunk/mcs/; revision=106353
2008-06-21 15:09:21 +00:00
Robert Jordan 28007d2993 In System.IO:
2008-05-29  Robert Jordan  <[email protected]>

	* Path.cs (InsecureGetFullPath): Call CanonicalizePath for
	UNC paths as well.
	* Path.cs (GetServerAndShare): New helper method.
	* Path.cs (SameRoot, CanonicalizePath): Add UNC support.
	Fixes #394681 and a bunch of TestGetFullPath unit cases.
	All changes are Win32 related.

In Test/System.IO:
2008-05-29  Robert Jordan  <[email protected]>

	* PathTest.cs (TestGetFullPathUnix, TestGetFullPathWindows):
	Factored out from the disabled TestGetFullPath test while fixing
	the issues mentioned by the ERROR comment and bug #394681.


svn path=/trunk/mcs/; revision=106188
2008-06-19 08:30:45 +00:00
Sebastien Pouliot 149655937e 2008-05-07 Sebastien Pouliot <[email protected]>
* CheckArgument.cs: Removed. Lots of unused code. The two methods
	used are now inlined into Path.cs
	* CheckPermission.cs: Removed. Lots of unused code.
	* Path.cs: Inlined two checks.
	[Found using Gendarme]


svn path=/trunk/mcs/; revision=102718
2008-05-07 12:05:42 +00:00
Sebastien Pouliot 59209d9257 2008-04-18 Sebastien Pouliot <[email protected]>
* Path.cs: Change PathSeparatorChars from private to internal since
	it's needed for IsolatedStorage.


svn path=/trunk/mcs/; revision=101171
2008-04-18 21:50:34 +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
Marek Safar a45cdde3fc 2008-03-20 Marek Safar <[email protected]>
* Path.cs (Combine): Call ToString to optimize concatenation.
	

svn path=/trunk/mcs/; revision=98675
2008-03-20 14:52:20 +00:00
Jb Evain 0eb1105589 2007-11-12 Juraj Skripsky <[email protected]>
* Path.cs (GetRandomFileName): Return filenames containing only
	characters from the range [a..z0..9] as MS.NET does. 


svn path=/trunk/mcs/; revision=89869
2007-11-17 19:29:36 +00:00
Miguel de Icaza c97c647b23 2007-11-01 Miguel de Icaza <[email protected]>
* Path.cs (GetDirectoryName): The paths returned from this routine
	should be canonical, not just a substring.   In addition to fixing
	this, it also fixes #324742.

svn path=/trunk/mcs/; revision=88708
2007-11-02 03:47:10 +00:00
Miguel de Icaza 937185f945 2007-03-05 Miguel de Icaza <[email protected]>
* Path.cs: Manually call FileStream and pass the new internal
	FileOptions.1 flag that means "This is a temporary file, use 600
	permissions". 

	* FileOptions.cs: Document the new private enum value.

svn path=/trunk/mcs/; revision=73771
2007-03-06 00:46:44 +00:00
Boris Kirzner e186082db9 Fix order of InvalidPathChars on windows.
svn path=/trunk/mcs/; revision=73099
2007-02-19 09:25:40 +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
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
Sebastien Pouliot f36b6a460c 2006-08-21 Sebastien Pouliot <[email protected]>
* Path.cs: Added internal method IsPathSubsetOf required to implement
	correctly FileIOPermission (better located here).


svn path=/trunk/mcs/; revision=64144
2006-08-21 14:28:27 +00:00
John Luke 3a334d1bcc 2006-06-03 John Luke <[email protected]>
* Path.cs: fix typo in [Obsolete] message


svn path=/trunk/mcs/; revision=61431
2006-06-03 15:50:07 +00:00
Atsushi Eno 48a3a32616 2006-04-28 Robert Jordan <[email protected]>
* Path.cs (GetPathRoot): Return just the \\server\share
	part of a UNC. Fixes #78147.

2006-04-28  Robert Jordan  <[email protected]>

	* PathTest.cs: Added tests for bug #78147.


svn path=/trunk/mcs/; revision=60033
2006-04-28 12:52:40 +00:00