changed organization of static files

removed: item.auth item.auth_path
added:   item.file_path, item.file_fs, item.file_type
now the path to a static file is a relative path
added: thumbnails (not finished yet)
fixed: db didn't correctly return the number of deleted items /DelItem() method/




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@696 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-12-10 21:07:01 +00:00
parent 9b29cce1a4
commit 36c8822e6c
41 changed files with 435 additions and 364 deletions

View File

@@ -12,6 +12,7 @@
#include "misc.h"
#include "log.h"
#include "templates/templates.h"
#include "utf8.h"
int Toi(const std::string & str, int base)
@@ -621,11 +622,12 @@ bool IsFile(const wchar_t * file)
struct stat sb;
static std::string afile;
AssignString(file, afile); // or it can be UTF-8 used
Ezc::WideToUTF8(file, afile);
return (stat(afile.c_str(), &sb) == 0);
}
bool IsFile(const std::wstring & file)
{
return IsFile(file.c_str());
@@ -638,17 +640,11 @@ static std::string adir;
if( !IsFile(dir) )
{
AssignString(dir, adir);
Ezc::WideToUTF8(dir, adir);
if( mkdir(adir.c_str(), priv) < 0 )
{
log << log1 << "Can't create a directory on fs: " << adir;
if( !Equal(dir, adir.c_str()) )
log << " original name was: " << dir;
log << logend;
log << log1 << "Can't create a directory on fs: " << adir << logend;
return false;
}
}
@@ -666,7 +662,7 @@ bool CreateDir(const std::wstring & dir, int priv)
// creating directories (can be more than one)
// 'dirs' can begin with a slash (will be skipped)
bool CreateDirs(const wchar_t * base_dir, const wchar_t * dirs, int priv)
bool CreateDirs(const wchar_t * base_dir, const wchar_t * dirs, int priv, bool skip_last)
{
static std::wstring temp;
const wchar_t * p = dirs;
@@ -688,11 +684,12 @@ const wchar_t * p = dirs;
break;
// taking the name
for( ; *p && *p!='/' ; ++p )
for( ; *p!=0 && *p!='/' ; ++p )
temp += *p;
if( !CreateDir(temp.c_str(), priv) )
return false;
if( !skip_last || *p!=0 )
if( !CreateDir(temp.c_str(), priv) )
return false;
temp += '/';
}
@@ -702,9 +699,9 @@ return true;
bool CreateDirs(const std::wstring & base_dir, const std::wstring & dirs, int priv)
bool CreateDirs(const std::wstring & base_dir, const std::wstring & dirs, int priv, bool skip_last)
{
return CreateDirs(base_dir.c_str(), dirs.c_str(), priv);
return CreateDirs(base_dir.c_str(), dirs.c_str(), priv, skip_last);
}
@@ -736,8 +733,8 @@ bool CopyFile(const wchar_t * src, const wchar_t * dst)
static std::string asrc, adst;
FILE * in, * out;
AssignString(src, asrc);
AssignString(dst, adst);
Ezc::WideToUTF8(src, asrc);
Ezc::WideToUTF8(dst, adst);
in = fopen(asrc.c_str(), "rb");
@@ -778,7 +775,7 @@ bool RemoveFile(const wchar_t * file)
{
static std::string afile;
AssignString(file, afile);
Ezc::WideToUTF8(file, afile);
return unlink(afile.c_str()) == 0;
}
@@ -795,8 +792,8 @@ bool RenameFile(const wchar_t * from, const wchar_t * to)
{
static std::string afrom, ato;
AssignString(from, afrom);
AssignString(to, ato);
Ezc::WideToUTF8(from, afrom);
Ezc::WideToUTF8(to, ato);
return rename(afrom.c_str(), ato.c_str()) == 0;
}
@@ -835,7 +832,7 @@ return name + i + 1;
}
Item::Auth SelectFileType(const wchar_t * file_name)
int SelectFileType(const wchar_t * file_name)
{
const wchar_t * ext = GetFileExt(file_name);
@@ -849,7 +846,7 @@ Item::Auth SelectFileType(const wchar_t * file_name)
EqualNoCase(ext, L"gif") ||
EqualNoCase(ext, L"bmp") ||
EqualNoCase(ext, L"png") )
return Item::auth_image;
return WINIX_ITEM_FILETYPE_IMAGE;
if( EqualNoCase(ext, L"pdf") ||
EqualNoCase(ext, L"doc") ||
@@ -857,9 +854,9 @@ Item::Auth SelectFileType(const wchar_t * file_name)
EqualNoCase(ext, L"txt") ||
EqualNoCase(ext, L"ods") ||
EqualNoCase(ext, L"odt") )
return Item::auth_document;
return WINIX_ITEM_FILETYPE_DOCUMENT;
return Item::auth_other;
return WINIX_ITEM_FILETYPE_UNKNOWN;
}