Использование WINDOWS
Добрый день!
TEMPLATE = app
CONFIG += console c++1z stl
CONFIG -= app_bundle
CONFIG -= qt
LIBS += -lstdc++fs -lpthread
SOURCES += \
main.cpp
#include <iostream>
#include <experimental/filesystem>
using namespace std;
namespace fs = std::experimental::filesystem;
namespace example_a
{
void example()
{
auto cur_p = fs::current_path();
cout << cur_p << endl;
cout << fs::current_path().root_path() << endl;
// auto space = fs::space(fs::current_path().root_path());
//cout << fs::current_path().root_directory() << endl;
fs::path p(fs::current_path().root_name());
fs::space_info sp = fs::space(p);
std::uintmax_t cap = sp.capacity;
cout << "Total:" << '\t' << cap << "Gb" << endl;
// cout << "Free :" << '\t' << space.free << "Gb" << endl;
// cout << "Avail:" << '\t' << space.available << "Gb" << endl;
// std::cin.get();
}
}
int main()
{
example_a::example();
}
"C:\\Users\\<name user>\\Documents\\build-untitled-Desktop_Qt_5_14_1_MinGW_32_bit-Debug"
"C:\\"
terminate called after throwing an instance of
'std::experimental::filesystem::v1::__cxx11::filesystem_error'
what(): filesystem error: cannot get free space: Unknown error [C:]
Подскажите пожалуйста как пользоваться таким функционалом под Windows 10, пример запускаю на QT. Под cygwin работает, но там Cmake, и результаты путей тянутся с эмулированой машины где корень /.
Вот код с той же машины не кути:
введите сюда код
#include <iostream>
#include <experimental/filesystem>
using namespace std;
namespace fs = std::experimental::filesystem::v1;
namespace example_a {
void example() {
auto cur_p = fs::current_path();
cout << cur_p << endl;
auto space = fs::space(fs::current_path().root_path());
cout << fs::current_path().root_directory() << endl;
cout << "Total:" << '\t' << space.capacity / 1024 / 1024 / 1024 << "Gb" << endl;
cout << "Free :" << '\t' << space.free / 1024 / 1024 / 1024 << "Gb" << endl;
cout << "Avail:" << '\t' << space.available / 1024 / 1024 / 1024 << "Gb" << endl;
std::cin.get();
}
}
int main()
{
example_a::example();
}
"/cygdrive/c/Users/<пользователь>i/CLionProjects/untitled2/cmake-build-debug"
"/"
Total: 525Gb
Free : 365Gb
Avail: 365Gb
cmake_minimum_required(VERSION 3.16)
project( untitled2 CXX )
set(CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_FLAGS "-fexceptions")
find_library(FILESYSTEM_LIBRARY filesystem)
add_executable(untitled2 main.cpp)
set( SOURCE_LIB main.cpp )
set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
target_link_libraries(${PROJECT_NAME} stdc++fs)
Хочу разобраться с ошибкой которую выводит в первом случае QT.
Подскажите пожалуйста как правильно работать с этим функционалом в Windows 10 под QT? Если конкретнее методом space и space_info, так как в первом примере выводит ошибку. Всю информацию указал какую имею.