Commit Graph
214 Commits
Author SHA1 Message Date
Ian Hays e8723ef1b5 Cleaned up tests for closed issues
Design review feedback brought about the closed issues dotnet/corefx#2537, dotnet/corefx#2403, dotnet/corefx#2402, dotnet/corefx#2369, dotnet/corefx#1728. This Commit cleaned up the tests around those decisions and removed OuterLoop from the GetSetTimes tests.


Commit migrated from https://github.com/dotnet/corefx/commit/3eb22a0ef2eb007b8fc8410d1a0fefc23311dc08
2015-08-11 14:53:51 -07:00
Stephen Toub 3d03788188 Merge pull request dotnet/corefx#2698 from justinvp/filestream_verifyhandleissync
Avoid the byte[] alloc in Win32FileStream.VerifyHandleIsSync

Commit migrated from https://github.com/dotnet/corefx/commit/328035557beac29cf51b1d00d0a634dd8a969aaa
2015-08-11 15:08:46 -04:00
Justin Van Patten 89d3a6bcbd Avoid the byte[] alloc in Win32FileStream.VerifyHandleIsSync
Call the native ReadFile and WriteFile interop functions directly,
passing a stack allocated byte, instead of allocating a byte[]
of length 1 on the heap. Added common error handling for
ERROR_INVALID_HANDLE.


Commit migrated from https://github.com/dotnet/corefx/commit/fe22fb00349400a198417f48979bd6bae7645b6e
2015-08-11 08:37:20 -07:00
Dmitry Turin f4055ca36c Pass message to ArgumentNullException in ReadAsync/WriteAsync
For consistency with synchronous Read/Write.


Commit migrated from https://github.com/dotnet/corefx/commit/9c21d464eb8d2f5da8c0e99bc00cd6f4a6e4812e
2015-08-11 12:39:16 +03:00
Jeremy Kuhne 3b5bfc51a3 Allow extended long path directories
Add methods for checking max length as it varies on path format.

Most code paths hit PathTooLong with GetFullPath- directories are a special
case as Win32 apis have a special limit (248) for directory creation.


Commit migrated from https://github.com/dotnet/corefx/commit/6f363e65bfd09bebdf09ba236f63da952948ba8e
2015-08-09 19:19:27 -07:00
Dmitry Turin 3310274f8b Return cached task at synchronous completion
Commit migrated from https://github.com/dotnet/corefx/commit/0c6ae1b2730bf1d9ecc31e481fa1b3296d91d0c2
2015-08-08 22:16:25 +03:00
Ian Hays 6f2190dc4e Fixed AccessTime, WriteTime, and CreationTime getters
Previously, AccessTime, WriteTime, and CreationTime would return DateTime objects with an unspecified DateTimeKind. This commit modified that behavior to have them instead return Local DateTime objects. Extra tests were also added to catch more potential error cases.

- Resolves dotnet/corefx#2603
- Resolves dotnet/corefx#2610


Commit migrated from https://github.com/dotnet/corefx/commit/df06e562a49b739655efff4b6b9f0faa23d09b78
2015-08-07 10:16:52 -07:00
Nick Guerrera b760fb6fb0 Merge pull request dotnet/corefx#2606 from nguerrera/add-errno-shim
Add errno shim (+ existing shim cleanup precursor)

Commit migrated from https://github.com/dotnet/corefx/commit/b9fc9e6d00fef3e83f2d80951e210b868627c328
2015-08-06 20:41:35 -07:00
stephentoub d6467ac0af Use RuntimeInformation across corefx for platform detection
This commit deletes our temporary Interop.PlatformDetection.cs mechanism and replaces usage of it with usage of System.Runtime.InteropServices.RuntimeInformation.dll.


Commit migrated from https://github.com/dotnet/corefx/commit/6861b625b391566544be9a60356c8c03b15e5fb5
2015-08-06 10:25:17 -04:00
Nick Guerrera f6ce429b8e Respond to PR feeback
* Defer conversions until necessary
* Rename Errno -> RawErrno
* Return null for ERANGE for strerror
* Add conversion helper for Error -> ErrorInfo
* Fix typos
* Remove unnecessary _POSIX_C_SOURCE define
* Fix names and sizes of managed FileStatus members
* Don't double-initialize ErrorInfo out param
* Zero out BirthTime when not available
* Put back newline at EOL
* Restore size of UnixFileSystemObject
* Use ignored local name for ignored error info
* Rename Interop.System to Interop.Sys to avoid
  collision with System namespace


Commit migrated from https://github.com/dotnet/corefx/commit/e82401bd3feea682832215d1e97dbb4bb73e211a
2015-08-06 06:52:01 +00:00
Nick Guerrera ef4deeef20 Use new errno shim from managed code
Commit migrated from https://github.com/dotnet/corefx/commit/2b01345b2a925400569269b1149afd645c77b790
2015-08-06 06:52:01 +00:00
Stephen Toub 7b28c3d30e Merge pull request dotnet/corefx#2630 from stephentoub/consolidate_tempfiles
Change System.IO.FileSystem.Tests to use FileCleanupTestBase

Commit migrated from https://github.com/dotnet/corefx/commit/37b0abb008ef543e57cbe02e0b4435bc1908a303
2015-08-05 12:20:05 -04:00
stephentoub 2e9fbca627 Change System.IO.FileSystem.Tests to use FileCleanupTestBase
When I rewrote the MemoryMappedFiles tests, I cribbed from the
System.IO.FileSystem test's base class and created a Common base class
that could be used by test projects that had temporary files to be cleaned up.
At the time, however, FileSystem's tests were undergoing heavy changes and
so I didn't update FileSystem's tests to use the common base.  Now that
things have quieted down, I've made that change.

In doing so, I made a few tweaks to the FileSystem tests, where tests were
assuming that the test directory was always in the current directory, and
the consolidated base class puts temporary files in the user's temporary
directory instead.


Commit migrated from https://github.com/dotnet/corefx/commit/d7a19e92824e8a038553de20abf2497db0424ddb
2015-08-04 23:24:06 -04:00
Stephen Toub d61e0ec805 Merge pull request dotnet/corefx#2588 from ianhays/linkunlink
Modified the Unix implementation of FileMove and fixed the corresponding broken FileSystemWatcher tests

Commit migrated from https://github.com/dotnet/corefx/commit/2f50375d7b84501179d87d3958a5a57fb458a73a
2015-08-04 23:15:39 -04:00
stephentoub b6046f97e0 Fix UnixFileSystem.MaxDirectoryName to be MaxPath
UnixFileSystem's override of MaxDirectoryName was assuming the property meant the maximum size of the file name of a directory, i.e. the component length, not the full path length of everything from the beginning of the root.  As a result, checks against MaxDirectoryName, such as in CreateDirectory, were failing incorrectly with longer path lengths.

The fix is just to return MaxPath from MaxDirectoryName; there's no difference on Unix.  I also added a test to cover this case, included a previously excluded test, and deleted a faulty test.


Commit migrated from https://github.com/dotnet/corefx/commit/5de40bfa898dc2a03fd5efb3f21ea2f69d16a94a
2015-08-04 21:48:54 -04:00
Ian Hays e6e252aabf Modified Unix File.Move to use link/unlink instead of rename
Changed the way the UnixFileSystem does File moving; it was previously implemented using the rename syscall but now uses a combination of link and unlink. The side effect of this change is that the FileSystemWatcher will now treat File.Move as a deletion.

- Resolves dotnet/corefx#2460
- Removed all tests from FileSystemWatcher that made calls to File.Move and consolidated them into a new file: FileSystemWatcher.MoveFile.cs. This new file separates tests into Windows and Unix categories and uses Theories to supply the input WatcherChangeType and whether a move should trigger an event for the given type. If we later decide to change the Unix behavior of MoveFile, changing the FileSystemWatcher tests will be a simple matter of flipping the boolean values for the affected tests.
- Fixed some comments in UnixFileSystem to be more specific to FileSystemWatcher
- Changed variable names for FSW Move tests to be more descriptive
- Modified FSW MoveFile and Utitlity helper classes to use guids so that they may be run concurrently.


Commit migrated from https://github.com/dotnet/corefx/commit/cae7c5116d46c0d98e6f0fb3526fa2a15945501a
2015-08-04 15:47:56 -07:00
Eric Mellino 66969e748b Re-lock dependencies with latest xunit
Commit migrated from https://github.com/dotnet/corefx/commit/795cbc75f8e167047a7c19cd7e21e99b9b9f4308
2015-08-03 16:40:33 -07:00
Eric Mellino c0015fc582 Move all tests to latest xunit beta
Commit migrated from https://github.com/dotnet/corefx/commit/7c12b0120834f92d5c591124f692ea1b64c6a877
2015-08-03 11:27:48 -07:00
Eric St. John 47aaf9fcf8 Use stable package dependencies and move our packages to post-stable versions
This change modifies the build to consume the stable version where available.

This disables building the dowlevel packages since we shipped them once as stable and we're done.
From here on out, we'll only build the latest version (except for a servicing event, which would
be handled by syncing to a hash).

I can't rev the package versions in the normal way yet (by modifying the assembly version of the contents)
because that turned out to be too big of a problem to tackle in this change. Instead I added a
parameter to the task that calculates package versions to do the rev for anything that was
stable, but only when building the package itself, not when calculating the dependencies.
This has the downside of not permitting a dependency on a incremented pre-release version if we've
shipped a stable version, but that is a small point in time problem until I can rev the assembly
versions.

[tfs-changeset: 1508664]


Commit migrated from https://github.com/dotnet/corefx/commit/ee1ec2891c7c65b46fa9dfb078636be503bb2a60
2015-07-31 15:47:51 -07:00
Ian Hays a9766775b0 - Added an overload to GetTestFilePath that takes an integer index parameter to add to the generated filename so that calls to the function within loops will be able to differentiate themselves
- Resolves dotnet/corefx#1434


Commit migrated from https://github.com/dotnet/corefx/commit/1dbfabb32d61a8c2db25c82bb22743bcc15c2ccb
2015-07-29 15:23:33 -07:00
Ian Hays 8d7c94172a - Resolves dotnet/corefx#2458. FileInfo.Open(FileMode.Append) didn't allow appending per so I modified FileInfo to allow it
- References dotnet/corefx#2460. File.Move and FileInfo.MoveTo no longer always overwrite the destination file; added a non-concurrent validity check to MoveFile in the Unix implementation to serve as a temporary solution.
- Resolves dotnet/corefx#2459. Reenabled Directory_CreateDirectory.DriveLetter_Unix as it's previous failures were not the fault of the method but of the system.
- Added test checks to work around the issue in dotnet/corefx#2537 until a final decision is reached for the desktop.
- Added Interop.Link to the Interop files for the (possible) implementation of File.Move
- Consolidated all of the related files that did nothing but inherit from other classes (e.g. File_GetFiles_str and File_GetFiles_str_str were consolidated into File_GetFiles)
- Removed the "partial" keyword from some test classes
- Finished overhauling all test cases that don't directly require solutions to Build System issues before being re-added (e.g. those that require networked drives or altering the current directory)
- Added some tests to increase code coverage slightly in some cases.
- All classes and files have been renamed to match the standard set by FileStream: only include parameters in the test/class name if there are overloads
- Modified the Unix behavior for distinguishing between a FileNotFoundException and a DirectoryNotFoundException to match that of Windows.
- Removed some redundant error checks that never catch
- DirectoryInfo.MoveTo(destPath) did not have checks for destinations with paths that are over MAXPATH. I added them to better match the behavior and error timing of Directory.Move(source, dest).


Commit migrated from https://github.com/dotnet/corefx/commit/481d5c645763da79145af50d123db3f4041aa05e
2015-07-29 08:04:18 -07:00
Justin Van Patten 2170b1c248 Reduce allocations in Win32 file system enumeration
- Lazily create and cache SearchResultHandler<TSource> instances
- Only allocate _searchStack when needed
- Remove the unnecessary SearchOption field on SearchData
- Replace SearchData class with unified PathPair struct with Unix.
- Remove the SearchResult class
- Pass WIN32_FIND_DATA by ref instead of copying (large struct)
- Various minor cleanup


Commit migrated from https://github.com/dotnet/corefx/commit/b5a268d22cbe2f10d7f347cd19fc89f5e16fa287
2015-07-27 10:59:29 -07:00
Wes Haggard 1917a92051 Add P2P reference for new IO tests to System.Runtime.Extensions
Until we can publish a new packages with the new System.Runtime.Extensions
implementation reference the locally built version. We need to change to a
P2P reference to avoid the race condition that is inherit in using
TestWithLocalLibraries. That can only be used if we know all the
dependencies are built first.


Commit migrated from https://github.com/dotnet/corefx/commit/018763c4dad4c0c1c1cc63befdcba249b7c11b05
2015-07-24 17:17:53 -07:00
Jeremy Kuhne 7f446020aa Allow extended syntax for paths
Additional work unblocking extended syntax. Fixes a few issues,
adds a number of tests, normalizes naming a bit more and moves/adds
helpers to shared code.

One nice side effect of this change is that you can now delete directories
that were undeletable before (if you had subdirectories that had trailing
spaces as one example).


Commit migrated from https://github.com/dotnet/corefx/commit/0721434e19e7f9ecf8bf6dba7485f6c86827388c
2015-07-23 19:17:34 -07:00
Jeremy Kuhne c25bace1a2 Merge pull request dotnet/corefx#2410 from JeremyKuhne/AllowExtended
Allow extended syntax for paths

Commit migrated from https://github.com/dotnet/corefx/commit/14e98f7acc0420c93218768f89dd69c9b4c12c86
2015-07-23 15:52:33 -07:00
Matt Mitchell b92c666b03 Enable globstar in run-test.sh
Globstar is not enabled by default, and a recent commit attempting to increase the number of directories being run for the Linux build actually skipped a bunch of stuff.  Enable globstar in the script (this is local) to fix.

Mark DriveLetter_Unix as a failing test, which appears to have snuck in in the meantime


Commit migrated from https://github.com/dotnet/corefx/commit/0b798760c7844e489bfb1432dd97b3ce184bb374
2015-07-23 10:28:52 -07:00
Jeremy Kuhne 911f36ebd9 Allow extended syntax for paths
Start on unblocking extended syntax. Moves some shared code to PathInternal.
Start adding tests for key scenarios. Temporarily use local libraries when
testing FileSystem (until we get an updated Runtime.Extensions package).


Commit migrated from https://github.com/dotnet/corefx/commit/72429b2ba76ebecb4c422a1d5eec05daf279b05e
2015-07-22 11:26:21 -07:00
Stephen Toub dc2151aa7b Merge pull request dotnet/corefx#2442 from stephentoub/license_headers
Add missing license headers to .cs files

Commit migrated from https://github.com/dotnet/corefx/commit/1bcb7dc4530a58bac2d7ce7743dc1e58a5c19a77
2015-07-22 13:42:47 -04:00
stephentoub b931aee629 Add missing license headers to .cs files
There are 77 .cs files in the repo lacking the standard license header we have on the other ~5400 .cs files.  This commit adds the missing ones.


Commit migrated from https://github.com/dotnet/corefx/commit/98157438d8790337f14341528f20d2f788a3279d
2015-07-21 18:52:55 -04:00
Ian Hays 55cc5920f4 Updated with PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/3098724684d3a9e2916fbf2100643301d9161127
2015-07-21 13:41:48 -07:00
Ian Hays 67541b0365 Update to FileSystem Tests
- Consolidated AccessTime, WriteTime, and CreationTime tests for FileInfo, File, DirectoryInfo, and Directory into one file per folder - GetSetTimes.cs
- Added some Unix tests
-Overhauled the Write/Read/Append tests for the File class and removed many duplicate tests
-Continuation of dotnet/corefx#2390


Commit migrated from https://github.com/dotnet/corefx/commit/5aebb5487de9fd481e3dd294c9d49aa25361dde2
2015-07-20 14:43:18 -07:00
Jeremy Kuhne 3d97204233 Merge pull request dotnet/corefx#2313 from JeremyKuhne/MinorCleanup
Move Windows File I/O helper methods into common.

Commit migrated from https://github.com/dotnet/corefx/commit/1701015acd323e7ba8def2e7a45770f63f9b03a9
2015-07-17 13:10:33 -07:00
Stephen Toub b8ed353401 Merge pull request dotnet/corefx#2118 from Maxwe11/FileStreamCompletionSource-cleanup
Remove unnecessary IAsyncResult implementation

Commit migrated from https://github.com/dotnet/corefx/commit/785e22118fd136651285c1f16312a667dd6dd52b
2015-07-16 16:09:29 -04:00
Stephen Toub 2b05e04fd9 Merge pull request dotnet/corefx#2367 from stephentoub/filestream_comments
Fix stale async-related comments in FileStream

Commit migrated from https://github.com/dotnet/corefx/commit/01a4dd8d3915965900e7a66f441d2b7f59881858
2015-07-15 14:27:15 -04:00
stephentoub ba06e5b368 Fix stale async-related comments in FileStream
Leftover after the async rewrite in dotnet/corefx#972.

Fixes dotnet/corefx#2117.


Commit migrated from https://github.com/dotnet/corefx/commit/07b5a17825f0c0130b2fae647ed36086d8562160
2015-07-15 12:46:41 -04:00
stephentoub bab02c72eb Ensure all Common includes use a <Link/>
Modifies various .csproj files to ensure that all Includes for files under Common use a <Link/> so that Visual Studio shows the files under a Common folder rather than flattened in the root.

Fixes dotnet/corefx#144


Commit migrated from https://github.com/dotnet/corefx/commit/264d92084d6c6366c3c23edaaab54a32f61d501b
2015-07-15 10:21:33 -04:00
Matt Ellis fdb8be4f7b Convert UTF-16 encoded files into UTF8
UTF16 encoded files trip up both Git and GitHub since the huristic they
use to determine if a file is binary or not depends on the existence of
null bytes in a file, which is common in UTF-16 encoded source.

This converts all the UTF-16 encoded files into UTF-8 with an explicit
byte order marker.


Commit migrated from https://github.com/dotnet/corefx/commit/b660da388085b5048f7dfc101d6d0634661a30dd
2015-07-13 15:37:11 -07:00
Ian Hays 98b6021d8d -System.IO.UnixFileSystem has an issue with the "overwrite" being interpreted backwards. I simply reversed the conditional statement to be correct. There were previously no tests to cover this possibility. Resolves dotnet/corefx#2276
-Updated over a dozen test files to use the modern Xunit syntax.
-Solved file-in-use concurrency issues in the altered tests. Resolves dotnet/corefx#1313, dotnet/corefx#2227
-Tests will no longer intermittently fail.
-Slightly improved code coverage for the FileSystem files whose tests I altered (Directory, DirectoryInfo, File, FileInfo)
-Most tests altered now inherit from similar tests to consolidate the testing robustness into as few locations as possible. For example, Directory_GetFiles_str now inherits from Directory_GetFileSystemEntries_str since the tests for Directory_GetFiles_str were the exact same ones as in Directory_GetFileSystemEntries_str anyways.
-All altered tests now use the System.IO.FileSystem.Tests namespace
-Renamed the File_WriteAll_all class name/file name to File_WriteAllText.
-I tested my changes on Windows overnight to verify that there is no more intermittent test failures. I didn't have to modify all of the files listed in dotnet/corefx#2227 to get them to pass; this concerns me but I found no way to replicate the errors I was receiving before. My guess would be that the tests in the files I didn't alter (e.g. File_WriteAll and File_ReadAll) used the same names as the tests I did alter but now that the tests I altered are changed they no longer share test file names and no longer fail as a result.


Commit migrated from https://github.com/dotnet/corefx/commit/d21ce06332afe7aba0a52491187983744c10b4a4
2015-07-13 13:00:43 -07:00
Jeremy Kuhne 8eed78fc4e Move helper methods into common.
This facilitates further IO work around long paths.


Commit migrated from https://github.com/dotnet/corefx/commit/b5982a3580e171b5f1fa086b93e7862a739dac4d
2015-07-10 16:09:09 -07:00
Stephen Toub a27f80706d Merge pull request dotnet/corefx#2289 from justinvp/ioiterator
Check the state before fetching the thread id

Commit migrated from https://github.com/dotnet/corefx/commit/d9f76a83d72afcea2902a1d4f7ab86cbc66a8a20
2015-07-09 13:43:52 -04:00
Justin Van Patten fdfe13b0b7 Check the state before fetching the thread id
To be consistent with a similar change to LINQ's Iterator.


Commit migrated from https://github.com/dotnet/corefx/commit/2b8337a37c1870acdf62810305d7d915154ad035
2015-07-09 10:06:44 -07:00
stephentoub 8ca4fb4dd8 Separate platform-specifics out of shared FileSystem code
In a few places, we still have platform-specific code in shared System.IO.FileSystem code.  In particular, DirectoryInfo is doing various manipulations related to Windows path roots that can result in doing the wrong thing on Unix, e.g. creating a DirectoryInfo for "C:" on Unix should be for the directory named "C:", but instead today it'll follow the Windows-specific logic of rerouting to target the current directory.  This commit fixes that.  It also moves some code used only in the Windows implementation into Windows-specific files (e.g. Directory.SearchData).


Commit migrated from https://github.com/dotnet/corefx/commit/2450018290375fd5a736d67cca8beec7db3a7c5c
2015-07-09 12:54:32 -04:00
Jonathan Miller 1f9230cbd4 Merge pull request dotnet/corefx#2140 from sokket/fsw
Fixing bugs in the OS X FileSystemWatcher so all tests pass

Commit migrated from https://github.com/dotnet/corefx/commit/67f73d03c8be9b36f924d510d495809440772bfb
2015-07-08 14:47:31 -07:00
Stephen Toub 77a4b37c2e Merge pull request dotnet/corefx#2270 from stephentoub/directory_iterate_list
Remove List<T> allocation from directory enumeration

Commit migrated from https://github.com/dotnet/corefx/commit/c5bb21f78468aa4646581cb0501290b878e1d18e
2015-07-08 16:02:55 -04:00
Jonathan Miller 6f59447d62 Fixing bugs in OS X FileSystemWatcher to make all tests pass
Commit migrated from https://github.com/dotnet/corefx/commit/b4e803af9e5974f0ea1278bc34755fe02663dc97
2015-07-08 12:27:29 -07:00
stephentoub 33da802f6b Remove List<T> allocation from directory enumeration
While working on some path-related functionality in System.IO.FileSystem, I noticed that our methods for iterating a directory are taking the enumerable of results, storing that into a list, and then converting that list into an array.  This commit changes four such methods to skip the middle-man.


Commit migrated from https://github.com/dotnet/corefx/commit/7b5006b867ffd73e870e1fa56a5be9622d356e7a
2015-07-08 10:09:46 -04:00
stephentoub 6a4d9d4794 Fix System.IO.FileSystem's PathHelpers for Unix
The FileSystem's PathHelpers internal class contains some utility functions for processing paths.  Some of these functions are copies of non-exposed Path members, while others are unique.  A bunch of those members have Windows-specifics coded into them, which is causing problems when dealing with various special paths on Unix, for example paths that end with double dots, relative paths that begin with a space, etc.

This commit splits PathHelpers into a PathHelpers.cs, PathHelpers.Windows.cs, and PathHelpers.Unix.cs, and implements the Unix functions appropriately.

It also fixes up a variety of tests that are now failing because they were expecting the Windows behavior.


Commit migrated from https://github.com/dotnet/corefx/commit/5945d8ced21c36e091290fb92f15a5c1f4cb2274
2015-07-07 22:12:38 -04:00
stephentoub f574e42e5c Fix FileSystem tests for Unix
A bunch of the FileSystem tests assume that certain paths are always invalid, but many such paths are valid on Unix.  This commit fixes the tests that are failing after the revised Path implementation.


Commit migrated from https://github.com/dotnet/corefx/commit/f0882d6673308cded7726cd5f3fd8e2b448a3415
2015-07-06 20:53:20 -04:00
stephentoub ea70db5dc5 Implement System.IO.Path on Unix
Previously, System.IO.Path was implemented in mscorlib (with calls into Win32 on Windows / the Win32 PAL layer in libcoreclr on Unix) and type-forwarded from System.Runtime.Extensions.  With dotnet/corefx#2234, we switched the Windows build to using System.IO.Path from System.Runtime.Extensions and Path.cs from corefx, but the Unix version was left still using the mscorlib implementation.  One of the reasons for switching to the Path.cs in corefx, however, was to better enable a bunch of fixes to the behavior of the Unix implementation.

This change implements Path.cs in corefx for Unix and switches the Unix builds (Linux, OS X, and FreeBSD) over to using the implementation in corefx rather than type-forwarding to mscorlib.

Primary changes:
- Defined MaxPath / MaxComponent length in the Unix build in terms of pathconf
- Implemented the Unix build's NormalizePath to properly handle normalizing unnecessary "/", ".", and ".."s in the path.
- Implemented the Unix build's GetTempPath in terms of the TMPDIR environment variable (same logic that's in the Win32 PAL layer's implementation).
- Implemented the Unix build's GetTempFileName in terms of mkstemps.
- Implemented the Unix build's GetRandomFileName in terms of OpenSSL's RAND_pseudo_bytes, same as is done in System.Security.Cryptography.RandomNumberGenerator (which we can't reference due to layering).
- Centralized the wrapping of getcwd, which is now used from both System.Runtime.Extensions and System.IO.FileSystem.  The previous usage of it always created a temporary array of size MaxPath, which can now be quite big, so the wrapper first tries to use stack space, and then graduates to retrying with larger and larger buffer sizes.
- Centralized the MaxPath and MaxName logic, which is now used by three libraries: System.Diagnostics.Process, System.IO.FileSystem, and now System.Runtime.Extensions.
- Centralized the throwing of PathTooLongException, as it now requires arguments for how long are the maximum path and component names.
- Cleaned up a few other minor things in the shared Path.cs (e.g. naming Boolean arguments) that were confusing me as I was working through the code.
- Added FreeBSD to the .sln and .csproj files, as otherwise the FreeBSD build for this library would be broken (previously it inherited the mscorlib implementation as did the other Unix OSes).
- Added a bunch of tests, some general across both Windows and Unix, but others specifically focused on Unix, which is more lenient than is Windows in the paths it allows.


Commit migrated from https://github.com/dotnet/corefx/commit/c4bc3bbfae8a9bf50defcfb8d6e13905f1209240
2015-07-06 20:53:17 -04:00
stephentoub 4f3ed512b0 Fix FileSystem enumeration with broken symlinks
Today when enumerating directories, we look only for entries with DT_DIR (directory) or DT_REG (regular file); if we encounter something unknown or a symlink, we stat to resolve it and determine whether it's actually an S_IFDIR (directory) or S_IFREG (regular file). There are (at least) two problems with this:

1) The stat to a symlink will fail if the symlink points to a non-existent entry.
2) We end up skipping lots of special files, e.g. FIFOs.

The commit changes our logic to simply special case directories: we treat everything as a file unless we're sure it's a directory. This directly fixes (2), and indirectly fixes (1): our logic for DirectoryExists already ignores any stat errors, returning false if the symlink couldn't be resolved, such that this naturally maps to our desired behavior of broken symlinks being categorized as a file.


Commit migrated from https://github.com/dotnet/corefx/commit/5428c98a421fe7e5907c050a7e820f5045b61e61
2015-07-06 17:28:08 -04:00