Merge branch 'master' of git.c3d2.de:sic++
Conflicts: src/sicccobject.H
This commit is contained in:
commit
2b4f7167a8
|
@ -13,12 +13,12 @@ class DynamicObjects
|
||||||
public:
|
public:
|
||||||
std::string render_object_list();
|
std::string render_object_list();
|
||||||
std::string cleanpath(const char * const);
|
std::string cleanpath(const char * const);
|
||||||
DynamicObjects(Routerin * merouterin) : _merouterin(merouterin){ };
|
DynamicObjects(Routerin * merouterin) : m_merouterin(merouterin){ };
|
||||||
~DynamicObjects() {};
|
~DynamicObjects() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _cleanpath (const char * const path);
|
std::string _cleanpath (const char * const path);
|
||||||
std::map<unsigned int, Sicobject *> _themap;
|
std::map<unsigned int, Sicobject *> m_themap;
|
||||||
const Routerin * _merouterin;
|
const Routerin * m_merouterin;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <ctime>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include "Routerin.H"
|
|
||||||
|
|
||||||
class Routerin;
|
|
||||||
|
|
||||||
class Sicobject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Sicobject() = delete;
|
|
||||||
|
|
||||||
Sicobject(const Routerin * master) :
|
|
||||||
_routerin(master),
|
|
||||||
_isvalid(false)
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
Sicobject(const Routerin *master, unsigned int idnum, std::string fname,size_t objsize,time_t upl_date) :
|
|
||||||
_size(objsize),
|
|
||||||
_idnum(idnum),
|
|
||||||
_routerin(master),
|
|
||||||
_isvalid(true),
|
|
||||||
_upl_date(upl_date),
|
|
||||||
_fname(fname)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
~Sicobject();
|
|
||||||
std::string get_loadurl(){
|
|
||||||
std::string retval = "files/"; //TODO add master.get_baseurl()
|
|
||||||
//TODO: add idnum
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string get_fname()
|
|
||||||
{
|
|
||||||
return _fname;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t get_size() { return _size;}
|
|
||||||
|
|
||||||
std::string bytesize_string()
|
|
||||||
{
|
|
||||||
std::ostringstream strm( std::ios_base::ate);
|
|
||||||
int i = 0;
|
|
||||||
size_t size = _size;
|
|
||||||
const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
|
|
||||||
while (size > 1024) {
|
|
||||||
size /= 1024;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
assert(i < 9);
|
|
||||||
strm << size << units[i];
|
|
||||||
return strm.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_t _size;
|
|
||||||
unsigned int _idnum;
|
|
||||||
const Routerin * _routerin;
|
|
||||||
bool _isvalid;
|
|
||||||
time_t _upl_date;
|
|
||||||
std::string _fname;
|
|
||||||
};
|
|
|
@ -9,54 +9,54 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
class Sicccobject {
|
class Sicccobject {
|
||||||
public:
|
public:
|
||||||
Sicccobject() {} // just for test cases
|
Sicccobject() {} // just for test cases
|
||||||
Sicccobject( const std::string& file,
|
Sicccobject( const std::string& file,
|
||||||
const std::string& ftype,
|
const std::string& ftype,
|
||||||
const std::string& fpath,
|
const std::string& fpath,
|
||||||
const size_t sz)
|
const size_t sz)
|
||||||
: filename(file),
|
: filename(file),
|
||||||
filetype(ftype),
|
filetype(ftype),
|
||||||
path(fpath),
|
path(fpath),
|
||||||
size(sz)
|
size(sz)
|
||||||
{
|
{
|
||||||
upload_date = std::chrono::system_clock::now();
|
upload_date = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sicccobject( const char *const file,
|
Sicccobject( const char *const file,
|
||||||
const char *const ftype,
|
const char *const ftype,
|
||||||
const char *const fpath,
|
const char *const fpath,
|
||||||
const size_t sz)
|
const size_t sz)
|
||||||
: filename(file),
|
: filename(file),
|
||||||
filetype(ftype),
|
filetype(ftype),
|
||||||
path(fpath),
|
path(fpath),
|
||||||
size(sz)
|
size(sz)
|
||||||
{
|
{
|
||||||
upload_date = std::chrono::system_clock::now();
|
upload_date = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sicccobject(const std::string& file,
|
Sicccobject(const std::string& file,
|
||||||
const std::string& ftype,
|
const std::string& ftype,
|
||||||
const std::string& fpath,
|
const std::string& fpath,
|
||||||
const size_t sz,
|
const size_t sz,
|
||||||
const std::chrono::time_point<std::chrono::system_clock>& date)
|
const std::chrono::time_point<std::chrono::system_clock>& date)
|
||||||
: filename(file),
|
: filename(file),
|
||||||
filetype(ftype),
|
filetype(ftype),
|
||||||
path(fpath),
|
path(fpath),
|
||||||
size(sz),
|
size(sz),
|
||||||
upload_date(date) { }
|
upload_date(date) { }
|
||||||
|
|
||||||
Sicccobject(const json_t*);
|
Sicccobject(const json_t*);
|
||||||
Sicccobject(const Sicccobject&);
|
Sicccobject(const Sicccobject&);
|
||||||
~Sicccobject() {}
|
~Sicccobject() {}
|
||||||
Sicccobject& operator = (const Sicccobject&);
|
Sicccobject& operator = (const Sicccobject&);
|
||||||
|
|
||||||
std::string get_filename() const { return filename; }
|
std::string get_filename() const { return filename; }
|
||||||
std::string get_filetype() const { return filetype; }
|
std::string get_filetype() const { return filetype; }
|
||||||
std::string get_path() const { return path; }
|
std::string get_path() const { return path; }
|
||||||
size_t get_size() const { return size; }
|
size_t get_size() const { return size; }
|
||||||
std::chrono::time_point<std::chrono::system_clock>
|
std::chrono::time_point<std::chrono::system_clock>
|
||||||
get_uploadtime() const { return upload_date; }
|
get_uploadtime() const { return upload_date; }
|
||||||
|
|
||||||
std::string get_pretty_sized() const
|
std::string get_pretty_sized() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue