Comments (7)
Actually, I think the problem is not limited to GetDirectoryName
; it's the NormalizePath
method that turns the path into an absolute path, and it's called everywhere. So basically, the library doesn't support relative paths at all...
from longpath.
OK, perhaps I was overly pessimistic... It's not as bad as I thought. The only affected methods were GetDirectoryName
and GetPathRoot
. I commited a fix and some extra unit tests (I also added a test for Combine
which might have been affected, but it was working fine)
from longpath.
Thanks, I'll have a look.
from longpath.
I just stumbled upon this:
Multithreaded applications and shared library code should not use the
GetFullPathName
function and should avoid using relative path names.
But NormalizeLongPath
relies on GetFullPathName
, and it's used everywhere...
The trouble is that for a relative path, GetFullPathName
uses the current directory to get the full path, and the current directory is set for the whole process, not for each thread; this makes this API inherently not thread-safe. I'm afraid the only way is to implement NormalizeLongPath
manually, rather than relying on GetFullPathName
(I looked at the BCL implementation of NormalizePath
, it's a bit scary....)
from longpath.
Just thinking: now that the reference source is under MIT license, it becomes possible to reuse part of the code from .NET to implement this properly :)
from longpath.
NormalizeLongPath
has to call GetFullPathName
in case a relative path was passed in. I see no way around that.
from longpath.
Merged PR ef12954
from longpath.
Related Issues (20)
- .NET Standard 2.0 support HOT 2
- DirectoryInfo.Refresh fails with UnauthorizedAccessException if executing principal has no access to parent folder HOT 1
- Path.GetPathRoot() throws ArgumentOutOfRangeException HOT 1
- The filename or extension is too long when creating a Directory on UNC
- Infinite sequence of elements when traversing the directory name consisting of single space HOT 3
- StreamWriter HOT 1
- Regression on 2.0.47.0 for DirectoryInfo HOT 2
- Can you document public methods HOT 1
- Mono support incomplete HOT 5
- File handles not being disposed HOT 2
- Path.GetPathRoot() throws IndexOutOfRangeException
- File.WriteAllText throws System.EntryPointNotFoundException on Mono HOT 1
- Endless loop
- File.Copy does two operations, for not win and then for win
- DirectoryInfo Delete mothod is throw exception HOT 1
- Have you considered merging with System.IO.Abstractions? HOT 1
- Error: Trying to create a parent directory, which exists but the current user has no permissions. HOT 1
- Consider checking for error upon subdirectory creation in Directory.CreateDirectory
- Long UNC pathname containing forward-slash (/) path separators is not normalised correctly
- Error with a really long and strange filename. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from longpath.