Comments (9)
_splitpath and _splitpath_s can only handle full path correctly, but you give it ".". So the path is broken.
I will try to fix this.
You are using tinydir_file_open, which is for opening a single file. But "." in Windows should be a folder. It's not recommended. Instead you can use tinydir_open.
And tinydir_open can handle path ".".
from tinydir.
It would be best if tinydir_file_open
detected this and returned an informative error like ENOENT
or EINVAL
(if .
is never a valid filename).
from tinydir.
@cxong Though "." may not be a valid file name, it could be good to return 0 as file.is_dir is set.
The point is _splitpath_s.
Here in VS 2010, _splitpath_s will make drive_buf and dir_name_buf full of messy code when using widechar, but not gcc.
So we need to fix this.
from tinydir.
@cxong Sorry to say that although _splitpath_s is not working fine, the tinydir_file_open itself are buggy. Whatever path it is, tinydir_file_open will always exit with Run-Time Failure #2 with _splitpath_s and widechar. Don't know why.
from tinydir.
@staticlibs Try #40
from tinydir.
@lautis0503 , about tinydir_open - I want to open a file and check whether it is a regular file or directory, get its name etc. tinydir_file_open is probably a right method for it.
Header updated with #40 worked for me in smoke testing after fixing the typo on line 630 (unneeded sizeof near ext_buf). Though specified sizes are probably incorrect there as they exceed the ones allowed in _wsplitpath_s - https://msdn.microsoft.com/en-us/library/8e46eyt7.aspx#Anchor_3 , from there - "File components larger than the corresponding manifest constants cause heap corruption."
Thanks for the fix!
from tinydir.
@staticlibs It is the right method.
@cxong _TINYDIR_PATH_MAX is too large for _splitpath. Maybe we need to write a function manually. What's your opinion?
from tinydir.
I guess _TINYDIR_PATH_MAX
should be MAX_PATH
instead for windows, which is 260 and doesn't break _splitpath
. I originally used 4096 just because it was the limit for linux and didn't think it hurt to have it larger than necessary.
from tinydir.
OK. I've done that.
from tinydir.
Related Issues (20)
- About how to use it in vs2010 under win7 HOT 5
- Compile error with newer glibc version: readdir_r is deprecated
- Compilation error with MSVC 14 x86 HOT 6
- Force use of ANSI on Windows HOT 3
- Compilation error on Windows 10 HOT 13
- MSVC and tinydir_file_open HOT 1
- Add Windows/Appveyor job
- Not all Linux systems store PATH_MAX in linux/limits.h HOT 2
- clang-tidy warning (tinydir.h:366) Call to 'malloc' has an allocation size of 0 HOT 1
- tinydir_file_open not works on win7
- PATH_MAX is not defined on linux when building with `-std=c99` HOT 3
- Possible WIN32_LEAN_AND_MEAN redefinition
- tinydir_readfile returns -1 when file is a broken link HOT 13
- Multiple sort options as a parameter HOT 2
- Cannot open drive root on Windows HOT 3
- Error C2632: 'int' followed by 'int' is illegal in windef.h file when trying to use the header file HOT 2
- Add Github Actions CI
- GCC11 warnings HOT 4
- Reporting security vulnerabilities HOT 2
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 tinydir.