Moin Moin. Ja der fehler entsteht durch die Funktion File_Status().
Hier ist mein restlicher Code. Vllt siehst du irgendwo einen Fehler.
Hauptklasse:
Code:
#include <filesystem>
class DIR_INFO
{
public:
std::filesystem::path m_path;
std::vector<std::string> File_Status_v;
DIR_INFO(std::filesystem::path const& path);
std::filesystem::path cur_path();
void MENU();
std::string filename();
std::string File_Status();
std::uintmax_t File_Size();
std::string Show_Perms();
std::string Show_Perms2();
private:
};
Klasse welche die Eingeschaften von der Klasse DIR:INFO erbt
Code:
#include "DIR_INFO.h"
class DIR_DATA : public DIR_INFO
{
private:
public:
DIR_DATA(std::filesystem::path const& path);
std::vector<DIR_INFO> files();
};
Main CCP
Code:
#include "DIR_INFO.h"
#include "DIR_DATA.h"
#include <iostream>
int
main(int argc, char** argv)
{
DIR_DATA dir{ "C:\\" };
dir.MENU();
for (auto& file : dir.files())
{
std::cout << std::setw(5) << dir.cur_path()
<< std::setw(50) << file.filename() //<< std::endl;
<< std::setw(15) << file.File_Status()// << std::endl;
<< std::setw(15) << file.File_Size() //<< std::endl;
<< std::setw(15) << file.Show_Perms() << std::endl;
}
}
Funktionen
Code:
#include "DIR_INFO.h"
#include "DIR_DATA.h"
#include <iostream>
DIR_INFO::DIR_INFO(std::filesystem::path const& path)
{
m_path = path;
}
std::filesystem::path DIR_INFO::cur_path()
{
return m_path;
}
std::vector<DIR_INFO> DIR_DATA::files()
{
std::vector<DIR_INFO> files;
try
{
for (auto const& entry : std::filesystem::directory_iterator( cur_path(), std::filesystem::directory_options::skip_permission_denied ))
{
files.push_back(entry.path());
}
return files;
}
catch (std::filesystem::filesystem_error e)
{
std::cout << "\n";
std::cout << "Fehler: " << e.what() << std::endl;
}
}
std::string DIR_INFO::filename()
{
return cur_path().filename().string();
}
void DIR_INFO::MENU()
{
std::cout << std::setw(5) << "Search_Manager_V0.60" << std::endl;
std::cout << std::setw(5) << "Pfad " <<
std::setw(61) << "Inhalt" <<
std::setw(15) << "STATUS" <<
std::setw(15) << "Size in Kb" <<
std::setw(15)<<"Rechte"<<std::endl;
}
Ich schau mal ob ich eine Lösung finde.