WIP: remove the old database abstraction layer

remove such classes:
- DbBase
- DbConn
- DbTextStream
- Db

while here:
- remove: TextStream, SLog, TexTextStream
This commit is contained in:
2024-06-22 18:03:54 +02:00
parent 5d457f3d4b
commit 6aa100f12c
138 changed files with 6658 additions and 12402 deletions
+18 -26
View File
@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2010-2022, Tomasz Sowa
* Copyright (c) 2010-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@
#include <ctime>
#include "image.h"
#include "core/misc.h"
#include "utf8/utf8.h"
#include "system.h"
#include "lock.h"
@@ -44,14 +45,6 @@ namespace Winix
{
void Image::SetDb(Db * pdb)
{
db = pdb;
}
void Image::SetConfig(Config * pconfig)
{
config = pconfig;
@@ -292,19 +285,13 @@ bool end;
void Image::Add(const std::wstring & in, TextStream<std::string> & out)
{
pt::wide_to_utf8(in, add_tempa);
out << add_tempa;
}
void Image::EscapePath(const std::string & path, TextStream<std::string> & out, bool clear_stream)
void Image::EscapePath(const std::string & path, pt::TextStream & out, bool clear_stream)
{
if( clear_stream )
out.Clear();
out.clear();
out << '"';
@@ -402,9 +389,9 @@ bool Image::CreateInputFileName()
// second thread (objects locked)
void Image::CreateTmpFileName()
{
stream_tmp_path.Clear();
stream_tmp_path.clear();
stream_tmp_path << config->upload_dir << L"/tmp/image_" << std::time(0);
pt::wide_to_utf8(stream_tmp_path.Str(), tmp_file_name);
stream_tmp_path.to_str(tmp_file_name);
}
@@ -427,8 +414,8 @@ bool Image::CreateCommand()
if( !CreateInputFileName() )
return false;
command.Clear();
Add(config->convert_cmd, command);
command.clear();
command << config->convert_cmd;
command << " ";
EscapePath(input_file_name, command, false);
@@ -472,7 +459,7 @@ bool Image::CreateCommand()
command << " ";
EscapePath(tmp_file_name, command, false);
log << log4 << "Image: running: " << command.Str() << logend;
log << log4 << "Image: running: " << command << logend;
return true;
@@ -553,7 +540,10 @@ void Image::SaveImage()
if( system->MakeFilePath(file_work, dst_path, thumb, true, config->upload_dirs_chmod, config->upload_group_int) )
{
if( RenameFile(stream_tmp_path.Str(), dst_path) )
std::wstring from;
stream_tmp_path.to_str(from);
if( RenameFile(from, dst_path) )
{
// it doesn't matter for us if there is an error when chmod/chown on a file
// the admin (root) will correct it
@@ -562,10 +552,10 @@ void Image::SaveImage()
}
else
{
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path.Str()
log << log1 << "Image: cannot move a temporary file: " << stream_tmp_path
<< ", to: " << dst_path << logend;
Winix::RemoveFile(stream_tmp_path.Str());
Winix::RemoveFile(from);
}
}
else
@@ -582,7 +572,9 @@ void Image::CreateImage()
{
if( CreateCommand() )
{
int res = std::system(command.CStr());
std::string command_str;
command.to_str(command_str);
int res = std::system(command_str.c_str());
if( res == 0 )
{