-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create directory and file like "D:/Logs/log.txt" #3079
Comments
It may have something to do with the fact that the Windows path separator is -"D:/Logs/log.txt"
+"D:\\Logs\\log.txt" |
Thank you for your response but it's not a problem of windows path separator. std::shared_ptrspdlog::logger logger = spdlog::daily_logger_mt("Log", "D:\\Logs\\log.txt"); |
Could be a permissions problem. |
I'm sure it's not a permissions problem becasuse spdlog::daily_logger_mt("Log", "\\Logs\\log.txt") is ok and in fact they are the same path on my computer. file: os-inl.h
|
This fix causes a problem on UNIX-like systems. The problem should be considered that spdlog/include/spdlog/details/os-inl.h Lines 538 to 540 in 238c9ff
spdlog/include/spdlog/details/os-inl.h Lines 178 to 190 in 238c9ff
Can you try to complete |
Since the Windows drive letter specification is one of
|
I don't know what effect this will have on UNIX-like systems, but _stat("D:/") and _mkdir("D:/") or _stat("D:/XX/") and _mkdir("D:/XX/") works on Windows. #ifdef _WIN32 |
The behavior when a path is a symbolic link differs depending on whether or not a trailing slash is used. |
You must also consider the case where a log file is to be created directly under the drive (e.g. spdlog/include/spdlog/details/os-inl.h Lines 547 to 555 in 238c9ff
|
Thank you for your patient reply and answer. But it's a real problem when I use spdlog to create log files and I need to manually create the parent directory. |
Please try adding to the workaround I came up with: #3079 (comment) |
@fanghtao So what was the fix ?? |
@gabime Thank you for your fix |
platform: windows
file: os-inl.h
line: 538
if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir)) {
return false; // return error if failed creating dir
}
this code will return false when create subdir = "D:/"
std::shared_ptrspdlog::logger logger = spdlog::daily_logger_mt("log", "/Logs/log.txt") ---- create directory succeed
std::shared_ptrspdlog::logger logger = spdlog::daily_logger_mt("log", "D:/Logs/log.txt") ---- can't create directory
The text was updated successfully, but these errors were encountered: