Commit a0ae27a6 authored by Murray Cumming's avatar Murray Cumming
Browse files

file_utils: Put in FileUtils namespace.

parent 05b88b73
......@@ -2171,7 +2171,7 @@ Glib::ustring AppWindow::ui_file_select_save(const Glib::ustring& old_file_uri)
const auto uri_chosen = fileChooser_Save->get_uri();
//Change the URI, to put the file (and its data folder) in a folder:
const auto uri = Utils::get_file_uri_without_extension(uri_chosen);
const auto uri = FileUtils::get_file_uri_without_extension(uri_chosen);
//Check whether the file exists, and that we have rights to it:
auto file = Gio::File::create_for_uri(uri);
......@@ -2377,7 +2377,7 @@ void AppWindow::on_menu_developer_export_backup()
// Start with a name based on the existing name.
const auto fileuri_old = document->get_file_uri();
const Glib::RefPtr<const Gio::File> file_old =
Gio::File::create_for_uri( Utils::get_file_uri_without_extension(fileuri_old) );
Gio::File::create_for_uri( FileUtils::get_file_uri_without_extension(fileuri_old) );
const auto old_basename = file_old->get_basename();
Glib::TimeVal timeval;
timeval.assign_current_time();
......
......@@ -377,7 +377,7 @@ int main(int argc, char* argv[])
//Save a copy, specifying the path to file in a directory:
filepath_dir =
Glom::Utils::get_file_path_without_extension(
Glom::FileUtils::get_file_path_without_extension(
Glib::build_filename(
group.m_arg_filepath_dir_output,
group.m_arg_filepath_name_output));
......
......@@ -213,7 +213,7 @@ Backend::InitErrors PostgresSelfHosted::initialize(const SlotProgress& slot_prog
// initdb creates a new postgres database cluster:
//Get file:// URI for the tmp/ directory:
const auto temp_pwfile = Utils::get_temp_file_path("glom_initdb_pwfile");
const auto temp_pwfile = FileUtils::get_temp_file_path("glom_initdb_pwfile");
const auto temp_pwfile_uri = Glib::filename_to_uri(temp_pwfile);
const auto pwfile_creation_succeeded = create_text_file(temp_pwfile_uri, password);
g_assert(pwfile_creation_succeeded);
......
......@@ -52,7 +52,7 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
auto db_dir = Gio::File::create_for_uri(m_database_directory_uri);
auto db_file = db_dir->get_child(database + ".db");
const auto file_exists = Glom::Utils::file_exists(db_file);
const auto file_exists = Glom::FileUtils::file_exists(db_file);
if(!file_exists)
{
//We don't warn here because the caller gets an exception anyway,
......@@ -96,7 +96,7 @@ Glib::RefPtr<Gnome::Gda::Connection> Sqlite::connect(const Glib::ustring& databa
{
// If the database directory is valid, then only the database (file) is
// missing, otherwise we pretend the "server" is not running.
if(Glom::Utils::file_exists(db_dir) &&
if(Glom::FileUtils::file_exists(db_dir) &&
(db_dir->query_file_type() == Gio::FILE_TYPE_DIRECTORY))
{
throw ExceptionConnection(ExceptionConnection::failure_type::NO_DATABASE);
......
......@@ -84,7 +84,7 @@ void LayoutItem_Image::set_image(const Gnome::Gda::Value& image)
Glib::ustring LayoutItem_Image::create_local_image_uri() const
{
return Utils::create_local_image_uri(m_image);
return FileUtils::create_local_image_uri(m_image);
}
} //namespace Glom
......
......@@ -5065,7 +5065,7 @@ Glib::ustring Document::extract_backup_file(const Glib::ustring& backup_uri, std
std::string contents_backup_file;
read_archive_entry_file_contents(a, entry, contents_backup_file);
backup_path = Utils::get_temp_file_path("glom_backup");
backup_path = FileUtils::get_temp_file_path("glom_backup");
Glib::file_set_contents(backup_path, contents_backup_file);
//std::cout << "debug: backup data path: " << backup_path << std::endl;
}
......
......@@ -31,7 +31,7 @@
namespace Glom
{
namespace Utils
namespace FileUtils
{
bool file_exists(const Glib::ustring& uri)
......@@ -97,7 +97,7 @@ static Glib::ustring get_directory_child_with_suffix(const Glib::ustring& uri_di
{
//Check the filename:
const std::string basename = child->get_basename();
if(string_remove_suffix(basename, suffix) != basename)
if(Utils::string_remove_suffix(basename, suffix) != basename)
return child->get_uri();
}
else if(recursive && file_type == Gio::FILE_TYPE_DIRECTORY)
......@@ -275,6 +275,6 @@ Glib::ustring create_local_image_uri(const Gnome::Gda::Value& value)
}
} //namespace Utils
} //namespace FileUtils
} //namespace Glom
......@@ -27,7 +27,7 @@
namespace Glom
{
namespace Utils
namespace FileUtils
{
bool file_exists(const Glib::ustring& uri);
......@@ -62,7 +62,7 @@ std::string get_temp_directory_path(const std::string& prefix = std::string());
*/
Glib::ustring get_temp_directory_uri(const std::string& prefix = std::string());
} //namespace Utils
} //namespace FileUtils
} //namespace Glom
......
......@@ -485,7 +485,7 @@ bool ReportBuilder::report_build_records_field(const FoundSet& found_set, xmlpp:
//Handle the value:
if(field_type == Field::glom_field_type::IMAGE)
nodeField->set_attribute("image_uri", Utils::create_local_image_uri(value));
nodeField->set_attribute("image_uri", FileUtils::create_local_image_uri(value));
else
{
Glib::ustring text_value = Conversions::get_text_for_gda_value(field_type, value, m_locale, field->get_formatting_used().m_numeric_format);
......@@ -580,7 +580,7 @@ std::string ReportBuilder::report_build_and_save(const FoundSet& found_set, cons
const auto contents = report_build(found_set, report);
//Save it to a temporary file and show it in a browser:
const auto temp_uri = Utils::get_temp_file_uri("glom_printout", "html");
const auto temp_uri = FileUtils::get_temp_file_uri("glom_printout", "html");
std::cout << G_STRFUNC << ": temp_uri=" << temp_uri << std::endl;
auto file = Gio::File::create_for_uri(temp_uri);
......
......@@ -253,7 +253,7 @@ bool check_postgres_is_available_with_warning()
if(!binpath.empty())
{
const auto uri_binpath = Glib::filename_to_uri(binpath);
if(Utils::file_exists(uri_binpath))
if(FileUtils::file_exists(uri_binpath))
return true;
}
......@@ -308,7 +308,7 @@ bool check_mysql_is_available_with_warning()
if(!binpath.empty())
{
const auto uri_binpath = Glib::filename_to_uri(binpath);
if(Utils::file_exists(uri_binpath))
if(FileUtils::file_exists(uri_binpath))
return true;
}
......
......@@ -618,7 +618,7 @@ static void make_file_read_only(const Glib::ustring& uri)
Glib::ustring ImageGlom::save_to_temp_file(bool show_progress)
{
Glib::ustring uri = Utils::get_temp_file_uri("glom_image");
Glib::ustring uri = FileUtils::get_temp_file_uri("glom_image");
if(uri.empty())
{
std::cerr << G_STRFUNC << ": : uri is empty.\n";
......
......@@ -22,7 +22,7 @@ bool check(const std::string& name, bool test, std::stringstream& report)
// Returns the file URI of the temporary created file, which will contain the buffer's contents.
static Glib::ustring create_file_from_buffer(const char* input, guint input_size)
{
const auto file_uri = Glom::Utils::get_temp_file_uri("glom_import_testdata");
const auto file_uri = Glom::FileUtils::get_temp_file_uri("glom_import_testdata");
if(file_uri.empty())
{
std::cerr << G_STRFUNC << ": file_uri was empty.\n";
......
......@@ -49,7 +49,7 @@ int main()
return EXIT_FAILURE;
}
g_assert( Glom::Utils::file_exists(uri) );
g_assert( Glom::FileUtils::file_exists(uri) );
//std::cout << "URI=" << uri << std::endl;
......
......@@ -59,7 +59,7 @@ int main()
{
Glom::libglom_init();
file_uri = Glom::Utils::get_temp_file_uri("testglom_document_autosave", ".glom");
file_uri = Glom::FileUtils::get_temp_file_uri("testglom_document_autosave", ".glom");
//Make sure that the file does not exist yet:
cleanup();
......
......@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
// Save the document:
document->set_allow_autosave(false);
const Glib::ustring temp_uri =
Glom::Utils::get_temp_file_uri("testglom_document", ".glom");
Glom::FileUtils::get_temp_file_uri("testglom_document", ".glom");
document->set_file_uri(temp_uri);
document->set_modified(); //TODO: Let save() succeed without this.
const auto saved = document->save();
......
......@@ -47,7 +47,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
return false;
}
const auto backup_uri = Glom::Utils::get_temp_directory_uri();
const auto backup_uri = Glom::FileUtils::get_temp_directory_uri();
backup_uri_tarball = document->save_backup_file(
backup_uri,
sigc::ptr_fun(&on_backup_progress));
......
......@@ -187,7 +187,7 @@ bool test_create_and_selfhost_new_empty(const std::shared_ptr<Glom::Document>& d
//For instance, /tmp/testglom/testglom.glom");
const std::string temp_filename = "testglom";
temp_filepath_dir =
Glom::Utils::get_temp_directory_path(temp_filename);
Glom::FileUtils::get_temp_directory_path(temp_filename);
if(!subdirectory_path.empty())
temp_filepath_dir = Glib::build_filename(temp_filepath_dir, subdirectory_path);
const auto temp_filepath = Glib::build_filename(temp_filepath_dir, temp_filename);
......
......@@ -100,7 +100,7 @@ int main()
return EXIT_FAILURE;
}
const auto po_file_uri = Glom::Utils::get_temp_file_uri("glom_export.po");
const auto po_file_uri = Glom::FileUtils::get_temp_file_uri("glom_export.po");
if(po_file_uri.empty())
{
std::cerr << G_STRFUNC << ": Could not generate a temporary file URI=\n";
......@@ -154,7 +154,7 @@ int main()
//Check that the .po file is valid:
check_po_file(po_file_path);
Glom::Utils::delete_file(po_file_uri);
Glom::FileUtils::delete_file(po_file_uri);
Glom::libglom_deinit();
......
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