Commit ff588fa3 authored by Pipelier Quentin's avatar Pipelier Quentin
Browse files

[+] Taille dans le tableau liste des playlists

parent d335e0d0
Pipeline #200233 passed with stages
in 20 minutes and 36 seconds
......@@ -2,6 +2,7 @@
#define INTERFACE_H
#include <gtkmm.h>
#include <iostream>
class Interface{
......@@ -23,6 +24,7 @@ class Interface{
ModelColumns m_Columns;
void addElementPlaylist(Glib::RefPtr<Gtk::ListStore> m_refTreeModel);
int getFileSize(const std::string &fileName);
};
#endif
#include "../header/interface.h"
#include <dirent.h>
#include <iostream>
#include <string>
#include <sys/types.h>
#include <fstream>
Interface::Interface(int argc, char* argv[])
{
......@@ -101,7 +101,7 @@ void Interface::addElementPlaylist(Glib::RefPtr<Gtk::ListStore> m_refTreeModel){
row[m_Columns.m_col_id] = count;
row[m_Columns.m_col_name] = name;
row[m_Columns.m_col_format] = "XSPF";
row[m_Columns.m_col_taille] = 0;
row[m_Columns.m_col_taille] = getFileSize(std::string(entry->d_name));
}else if(std::string(entry->d_name).find(m3u) != std::string::npos){
Gtk::TreeModel::Row row = *(m_refTreeModel->append());
count++;
......@@ -111,9 +111,25 @@ void Interface::addElementPlaylist(Glib::RefPtr<Gtk::ListStore> m_refTreeModel){
row[m_Columns.m_col_id] = count;
row[m_Columns.m_col_name] = name;
row[m_Columns.m_col_format] = "M3U";
row[m_Columns.m_col_taille] = 0;
row[m_Columns.m_col_taille] = getFileSize(std::string(entry->d_name));
}
}
closedir(dir);
}
}
int Interface::getFileSize(const std::string &fileName){
std::ifstream file(fileName.c_str(), std::ifstream::in | std::ifstream::binary);
if(!file.is_open())
{
return -1;
}
file.seekg(0, std::ios::end);
int fileSize = file.tellg();
file.close();
return fileSize;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment