[niepce] boost path removal.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] boost path removal.
- Date: Fri, 8 May 2009 14:58:34 -0400 (EDT)
commit 788035738ad85358cffeb403101471dbba5f728b
Author: Hubert Figuiere <hub figuiere net>
Date: Tue May 5 14:11:55 2009 -0400
boost path removal.
---
ChangeLog | 2 +
README | 1 -
configure.ac | 1 -
src/engine/db/Makefile.am | 1 -
src/engine/db/filebundle.cpp | 18 ++---
src/engine/db/filebundle.hpp | 19 ++---
src/engine/db/fsfile.cpp | 2 +-
src/engine/db/fsfile.hpp | 7 +-
src/engine/db/libfile.cpp | 7 +-
src/engine/db/libfile.hpp | 7 +-
src/engine/db/library.cpp | 52 ++++++-------
src/engine/db/library.hpp | 24 +++---
src/engine/db/test_library.cpp | 28 ++++----
src/engine/library/Makefile.am | 2 +-
src/engine/library/commands.cpp | 5 +-
src/engine/library/commands.hpp | 2 +-
src/engine/library/thumbnailcache.cpp | 18 ++--
src/engine/library/thumbnailcache.hpp | 5 +-
src/fwk/toolkit/application.cpp | 2 +
src/fwk/toolkit/imageloader.cpp | 42 ++++++----
src/fwk/toolkit/imageloader.hpp | 20 ++++-
src/fwk/toolkit/mimetype.cpp | 11 +--
src/fwk/utils/Makefile.am | 14 +++-
src/fwk/utils/exempi.cpp | 41 +++++-----
src/fwk/utils/exempi.hpp | 3 +-
src/fwk/utils/files.cpp | 49 +++++++-----
src/fwk/utils/files.hpp | 13 ++--
src/fwk/utils/fsutils.hpp | 6 +-
src/fwk/utils/pathutils.cpp | 139 +++++++++++++++++++++++++++++++++
src/fwk/utils/pathutils.hpp | 65 +++++++++++++++
src/fwk/utils/t/testpathutils.cpp | 41 ++++++++++
src/fwk/utils/testfiles.cpp | 5 +
src/fwk/utils/testufrawmeta.cpp | 12 ++-
src/fwk/utils/testxmp.cpp | 8 ++-
src/fwk/utils/ufrawmeta.cpp | 12 +--
src/fwk/utils/ufrawmeta.hpp | 6 +-
src/libraryclient/Makefile.am | 2 +-
src/libraryclient/libraryclient.cpp | 4 +-
src/libraryclient/test_worker.cpp | 2 +
src/ncr/image.cpp | 6 +-
src/ncr/image.hpp | 3 +-
src/niepce/Makefile.am | 3 +-
src/niepce/main.cpp | 6 --
43 files changed, 486 insertions(+), 230 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 331e333..8f0a7a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
* src/fwk/toolkit/dialog.hpp (fwk): Remove a leftover
boost::shared_ptr<>
+ * Remove boost::filesystem.
+
2009-05-07 Hubert Figuiere <hub figuiere net>
* src/fwk/toolkit/mimetype.{cpp,hpp}:
diff --git a/README b/README
index 498d649..e03ca6a 100644
--- a/README
+++ b/README
@@ -31,7 +31,6 @@ cairomm
sqlite3
libxml > 2.5.0
boost 1.34
- -boost filesystem
-boost test (for the unit test)
exempi >= 2.0.0
libopenraw >= 0.0.5
diff --git a/configure.ac b/configure.ac
index c6617a3..13447ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,6 @@ PKG_CHECK_MODULES(GOOCANVASMM, [goocanvasmm-1.0 >= $LIBGOOCANVASMM_VERSION])
BOOST_REQUIRE([$BOOST_VERSION])
BOOST_BIND
BOOST_CONVERSION
-BOOST_FILESYSTEM
BOOST_FORMAT
BOOST_FUNCTION
BOOST_SMART_PTR
diff --git a/src/engine/db/Makefile.am b/src/engine/db/Makefile.am
index 64bca47..5c28029 100644
--- a/src/engine/db/Makefile.am
+++ b/src/engine/db/Makefile.am
@@ -13,7 +13,6 @@ TEST_LIBS = \
$(top_builddir)/src/fwk/libfwk.a \
@LIBGTKMM_LIBS@ \
@BOOST_UNIT_TEST_FRAMEWORK_LIBS@ \
- @BOOST_FILESYSTEM_LIBS@ \
@LIBGLIBMM_LIBS@ \
@SQLITE3_LIBS@ @EXEMPI_LIBS@
diff --git a/src/engine/db/filebundle.cpp b/src/engine/db/filebundle.cpp
index 4982a94..fb3a937 100644
--- a/src/engine/db/filebundle.cpp
+++ b/src/engine/db/filebundle.cpp
@@ -18,21 +18,19 @@
*/
-#include <boost/version.hpp>
-#include <boost/filesystem/convenience.hpp>
-
#include "filebundle.hpp"
#include "fwk/utils/debug.hpp"
+#include "fwk/utils/pathutils.hpp"
#include "fwk/toolkit/mimetype.hpp"
namespace db {
void
-FileBundle::add(const boost::filesystem::path & path)
+FileBundle::add(const std::string & path)
{
// TODO make it more reliable with more tests.
- fwk::MimeType type(path.string());
+ fwk::MimeType type(path);
if(type.isImage()) {
if(type.isDigicamRaw()) {
@@ -54,7 +52,7 @@ FileBundle::add(const boost::filesystem::path & path)
m_xmp_sidecar = path;
}
else {
- DBG_OUT("Unkown file %s\n", path.string().c_str());
+ DBG_OUT("Unkown file %s\n", path.c_str());
}
}
@@ -71,12 +69,8 @@ FileBundle::filter_bundles(const utils::FileList::Ptr & files)
for(utils::FileList::const_iterator iter = files->begin();
iter != files->end(); ++iter)
{
- std::string basename;
-#if BOOST_VERSION >= 103600
- basename = iter->stem();
-#else
- basename = boost::filesystem::basename(*iter);
-#endif
+ std::string basename = fwk::path_stem(*iter);
+
if(basename != current_base) {
current_base = basename;
current_bundle = FileBundle::Ptr(new FileBundle());
diff --git a/src/engine/db/filebundle.hpp b/src/engine/db/filebundle.hpp
index 2f864ca..aabced1 100644
--- a/src/engine/db/filebundle.hpp
+++ b/src/engine/db/filebundle.hpp
@@ -21,9 +21,8 @@
#define __DB_FILEBUNDLE_H_
#include <list>
-
+#include <string>
#include <tr1/memory>
-#include <boost/filesystem/path.hpp>
#include "fwk/utils/files.hpp"
#include "engine/db/libfile.hpp"
@@ -39,20 +38,20 @@ public:
typedef std::tr1::shared_ptr<List> ListPtr;
/** add a file to a bundle. Will determine what type it is. */
- void add(const boost::filesystem::path & path);
- const boost::filesystem::path & main_file() const
+ void add(const std::string & path);
+ const std::string & main_file() const
{ return m_main; }
- const boost::filesystem::path & jpeg() const
+ const std::string & jpeg() const
{ return m_jpeg; }
- const boost::filesystem::path & sidecar() const
+ const std::string & sidecar() const
{ return m_xmp_sidecar; }
static ListPtr filter_bundles(const utils::FileList::Ptr & files);
private:
- boost::filesystem::path m_main;
- boost::filesystem::path m_xmp_sidecar;
- boost::filesystem::path m_jpeg;
- boost::filesystem::path m_thumbnail;
+ std::string m_main;
+ std::string m_xmp_sidecar;
+ std::string m_jpeg;
+ std::string m_thumbnail;
};
diff --git a/src/engine/db/fsfile.cpp b/src/engine/db/fsfile.cpp
index f2c84c0..cba2076 100644
--- a/src/engine/db/fsfile.cpp
+++ b/src/engine/db/fsfile.cpp
@@ -24,7 +24,7 @@
namespace db {
-FsFile::FsFile(int _id, const boost::filesystem::path & _path)
+FsFile::FsFile(int _id, const std::string & _path)
: m_id(_id), m_path(_path)
{
}
diff --git a/src/engine/db/fsfile.hpp b/src/engine/db/fsfile.hpp
index 488dc76..a4534df 100644
--- a/src/engine/db/fsfile.hpp
+++ b/src/engine/db/fsfile.hpp
@@ -22,7 +22,6 @@
#include <string>
#include <tr1/memory>
-#include <boost/filesystem/path.hpp>
namespace db {
@@ -33,15 +32,15 @@ class FsFile
public:
typedef std::tr1::shared_ptr< FsFile > Ptr;
- FsFile(int id, const boost::filesystem::path & path);
+ FsFile(int id, const std::string & path);
int id()
{ return m_id; }
- const boost::filesystem::path & path() const
+ const std::string & path() const
{ return m_path; }
private:
int m_id;
- boost::filesystem::path m_path; /**< absolute path */
+ std::string m_path; /**< absolute path */
};
}
diff --git a/src/engine/db/libfile.cpp b/src/engine/db/libfile.cpp
index f6ec13f..a62cb45 100644
--- a/src/engine/db/libfile.cpp
+++ b/src/engine/db/libfile.cpp
@@ -22,17 +22,16 @@
#include "libfile.hpp"
#include "metadata.hpp"
-namespace bfs = boost::filesystem;
namespace db {
-LibFile::LibFile(int _id, int _folderId, int _fsfileid, const bfs::path & p,
+LibFile::LibFile(int _id, int _folderId, int _fsfileid, const std::string & p,
const std::string & _name )
: m_id(_id), m_folderId(_folderId),
m_name(_name),
- m_main_file(_fsfileid, p),
+ m_main_file(_fsfileid, p),
m_orientation(0), m_rating(0), m_label(0),
- m_file_type(FILE_TYPE_UNKNOWN)
+ m_file_type(FILE_TYPE_UNKNOWN)
{
}
diff --git a/src/engine/db/libfile.hpp b/src/engine/db/libfile.hpp
index 473b136..3726a4f 100644
--- a/src/engine/db/libfile.hpp
+++ b/src/engine/db/libfile.hpp
@@ -23,7 +23,6 @@
#include <string>
#include <list>
#include <tr1/memory>
-#include <boost/filesystem/path.hpp>
#include "fwk/toolkit/mimetype.hpp"
#include "engine/db/keyword.hpp"
@@ -51,7 +50,7 @@ public:
static FileType mimetype_to_filetype(fwk::MimeType mime);
LibFile(int id, int folderId, int fsfileid,
- const boost::filesystem::path & p,
+ const std::string & p,
const std::string & name );
virtual ~LibFile();
@@ -61,7 +60,7 @@ public:
{ return m_folderId; }
const std::string & name() const
{ return m_name; }
- const boost::filesystem::path & path() const
+ const std::string & path() const
{ return m_main_file.path(); }
// Storage::Ptr storage() const;
@@ -96,7 +95,7 @@ public:
* because the Gtk stuff want that.
*/
const std::string uri() const
- { return std::string("file://") + m_main_file.path().string(); }
+ { return std::string("file://") + m_main_file.path(); }
/** check is the library file is at uri
* @return true of the uri match
* @todo
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index ffc2822..a913795 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -24,8 +24,6 @@
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <boost/bind.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/convenience.hpp>
#include "fwk/base/color.hpp"
#include "niepce/notifications.hpp"
@@ -34,6 +32,7 @@
#include "fwk/utils/exception.hpp"
#include "fwk/utils/exempi.hpp"
#include "fwk/utils/debug.hpp"
+#include "fwk/utils/pathutils.hpp"
#include "fwk/utils/db/sqlite/sqlitecnxmgrdrv.hpp"
#include "fwk/utils/db/sqlite/sqlitecnxdrv.hpp"
#include "fwk/utils/db/sqlstatement.hpp"
@@ -43,7 +42,6 @@
using fwk::NotificationCenter;
using eng::Label;
-namespace bfs = boost::filesystem;
namespace db {
@@ -52,13 +50,13 @@ const char * s_databaseName = "niepcelibrary.db";
Library::Library(const std::string & dir, const NotificationCenter::Ptr & nc)
: m_maindir(dir),
- m_dbname(m_maindir / s_databaseName),
+ m_dbname(m_maindir + "/" + s_databaseName),
m_dbmgr(new db::sqlite::SqliteCnxMgrDrv()),
m_notif_center(nc),
m_inited(false)
{
DBG_OUT("dir = %s", dir.c_str());
- db::DBDesc desc("", 0, m_dbname.string());
+ db::DBDesc desc("", 0, m_dbname);
m_dbdrv = m_dbmgr->connect_to_db(desc, "", "");
m_inited = init();
@@ -217,13 +215,13 @@ int Library::checkDatabaseVersion()
}
-int Library::addFsFile(const bfs::path & file)
+int Library::addFsFile(const std::string & file)
{
int ret = -1;
SQLStatement sql(boost::format("INSERT INTO fsfiles (path)"
" VALUES ('%1%')")
- % file.string());
+ % file);
if(m_dbdrv->execute_statement(sql)) {
int64_t id = m_dbdrv->last_row_id();
DBG_OUT("last row inserted %d", (int)id);
@@ -232,9 +230,9 @@ int Library::addFsFile(const bfs::path & file)
return ret;
}
-boost::filesystem::path Library::getFsFile(int id)
+std::string Library::getFsFile(int id)
{
- boost::filesystem::path p;
+ std::string p;
SQLStatement sql(boost::format("SELECT path FROM fsfiles"
" WHERE id='%1%'")
% id);
@@ -255,7 +253,7 @@ boost::filesystem::path Library::getFsFile(int id)
}
-int Library::addFile(int folder_id, const bfs::path & file, bool manage)
+int Library::addFile(int folder_id, const std::string & file, bool manage)
{
int ret = -1;
DBG_ASSERT(!manage, "manage not supported");
@@ -263,7 +261,7 @@ int Library::addFile(int folder_id, const bfs::path & file, bool manage)
try {
int32_t rating, label_id, orientation;
std::string label;
- fwk::MimeType mime = fwk::MimeType(file.string());
+ fwk::MimeType mime = fwk::MimeType(file);
db::LibFile::FileType file_type = db::LibFile::mimetype_to_filetype(mime);
utils::XmpMeta meta(file, file_type == db::LibFile::FILE_TYPE_RAW);
label_id = 0;
@@ -289,7 +287,7 @@ int Library::addFile(int folder_id, const bfs::path & file, bool manage)
" '%4%', '%4%',"
" '%5%', '%6%', '%7%', '%8%', '%9%',"
" ?1);")
- % fs_file_id % file.leaf() % folder_id
+ % fs_file_id % fwk::path_basename(file) % folder_id
% time(NULL)
% orientation % creation_date % rating
% label_id % file_type);
@@ -325,13 +323,13 @@ int Library::addFile(int folder_id, const bfs::path & file, bool manage)
}
-int Library::addFileAndFolder(const bfs::path & folder, const bfs::path & file,
+int Library::addFileAndFolder(const std::string & folder, const std::string & file,
bool manage)
{
LibFolder::Ptr f;
f = getFolder(folder);
if(f == NULL) {
- ERR_OUT("Folder %s not found", folder.string().c_str());
+ ERR_OUT("Folder %s not found", folder.c_str());
}
return addFile(f ? f->id() : -1, file, manage);
}
@@ -395,12 +393,12 @@ bool Library::addJpegFileToBundle(int file_id, int fsfile_id)
}
-LibFolder::Ptr Library::getFolder(const bfs::path & folder)
+LibFolder::Ptr Library::getFolder(const std::string & folder)
{
LibFolder::Ptr f;
SQLStatement sql(boost::format("SELECT id,name "
"FROM folders WHERE path='%1%'")
- % folder.string());
+ % folder);
try {
if(m_dbdrv->execute_statement(sql)) {
@@ -421,18 +419,19 @@ LibFolder::Ptr Library::getFolder(const bfs::path & folder)
}
-LibFolder::Ptr Library::addFolder(const bfs::path & folder)
+LibFolder::Ptr Library::addFolder(const std::string & folder)
{
LibFolder::Ptr f;
SQLStatement sql(boost::format("INSERT INTO folders "
"(path,name,vault_id,parent_id) "
"VALUES('%1%', '%2%', '0', '0')")
- % folder.string() % folder.leaf());
+ % folder % fwk::path_basename(folder));
try {
if(m_dbdrv->execute_statement(sql)) {
int64_t id = m_dbdrv->last_row_id();
DBG_OUT("last row inserted %d", (int)id);
- f = LibFolder::Ptr(new LibFolder((int)id, folder.leaf()));
+ f = LibFolder::Ptr(new LibFolder((int)id,
+ fwk::path_basename(folder)));
}
}
catch(utils::Exception & e)
@@ -478,8 +477,7 @@ static LibFile::Ptr getFileFromDbRow(const db::IConnectionDriver::Ptr & dbdrv)
dbdrv->get_column_content(8, fsfid);
DBG_OUT("found %s", pathname.c_str());
LibFile::Ptr f(new LibFile(id, fid, fsfid,
- bfs::path(pathname),
- name));
+ pathname, name));
int32_t val;
dbdrv->get_column_content(4, val);
f->setOrientation(val);
@@ -870,26 +868,26 @@ bool Library::rewriteXmpForId(int id)
m_dbdrv->get_column_content(0, xmp_buffer);
m_dbdrv->get_column_content(1, main_file_id);
m_dbdrv->get_column_content(2, xmp_file_id);
- boost::filesystem::path spath = getFsFile(main_file_id);
+ std::string spath = getFsFile(main_file_id);
DBG_ASSERT(!spath.empty(), "couldn't find the main file");
- boost::filesystem::path p;
+ std::string p;
if(xmp_file_id > 0) {
p = getFsFile(xmp_file_id);
DBG_ASSERT(!p.empty(), "couldn't find the xmp file path");
}
if(p.empty()) {
- p = boost::filesystem::change_extension(spath, ".xmp");
+ p = fwk::path_replace_extension(spath, ".xmp");
DBG_ASSERT(p != spath, "path must have been changed");
}
- if(exists(p)) {
- DBG_OUT("%s already exist", p.string().c_str());
+ if(fwk::path_exists(p)) {
+ DBG_OUT("%s already exist", p.c_str());
// TODO backup
}
// TODO probably a faster way to do that
utils::XmpMeta xmppacket;
xmppacket.unserialize(xmp_buffer.c_str());
// TODO use different API
- FILE * f = fopen(p.string().c_str(), "w");
+ FILE * f = fopen(p.c_str(), "w");
if(f) {
std::string sidecar = xmppacket.serialize();
fwrite(sidecar.c_str(), sizeof(std::string::value_type),
diff --git a/src/engine/db/library.hpp b/src/engine/db/library.hpp
index 2878bea..4f2d520 100644
--- a/src/engine/db/library.hpp
+++ b/src/engine/db/library.hpp
@@ -26,7 +26,6 @@
#include <tr1/memory>
#include <boost/any.hpp>
-#include <boost/filesystem/path.hpp>
#include "fwk/toolkit/notificationcenter.hpp"
#include "fwk/utils/db/iconnectiondriver.hpp"
@@ -80,10 +79,10 @@ public:
// void setMainDir(const std::string & dir)
// { m_maindir = dir; }
/** return the main directory */
- const boost::filesystem::path & mainDir() const
+ const std::string & mainDir() const
{ return m_maindir; }
/** get the path to the DB file */
- const boost::filesystem::path & dbName() const
+ const std::string & dbName() const
{ return m_dbname; }
void notify(NotifyType t, const boost::any & param);
@@ -93,28 +92,27 @@ public:
* @param file the file path
* @param manage pass true it the library *manage* the file. Currently unsupported.
*/
- int addFileAndFolder(const boost::filesystem::path & folder,
- const boost::filesystem::path & file, bool manage);
+ int addFileAndFolder(const std::string & folder,
+ const std::string & file, bool manage);
/** add a fs file to the library
* @param file the file path
* @return the id of the fs_file, -1 in case of error
*/
- int addFsFile(const boost::filesystem::path & file);
+ int addFsFile(const std::string & file);
/** Get a FsFile from an id
* @param id the id of the FsFile
* @return the path. Empty if not found.
*/
- boost::filesystem::path getFsFile(int id);
+ std::string getFsFile(int id);
/** add a file to the library
* @param folder_id the id of the containing folder
* @param file the file path
* @param manage pass true it the library *manage* the file. Currently unsupported.
*/
- int addFile(int folder_id, const boost::filesystem::path & file,
- bool manage);
+ int addFile(int folder_id, const std::string & file, bool manage);
/** add a bundle of files to the library
* @param folder_id the id of the containing folder
@@ -140,12 +138,12 @@ public:
* @param folder the folder path to check
* @return the folder, NULL if not found
*/
- LibFolder::Ptr getFolder(const boost::filesystem::path & folder);
+ LibFolder::Ptr getFolder(const std::string & folder);
/** Add a folder
* @param folder the folder path
*/
- LibFolder::Ptr addFolder(const boost::filesystem::path & folder);
+ LibFolder::Ptr addFolder(const std::string & folder);
/** List all the folders.
* @param l the list of LibFolder
*/
@@ -207,8 +205,8 @@ private:
bool setInternalMetaDataInt(int file_id, const char* col,
int32_t value);
- boost::filesystem::path m_maindir;
- boost::filesystem::path m_dbname;
+ std::string m_maindir;
+ std::string m_dbname;
db::IConnectionManagerDriver::Ptr m_dbmgr;
db::IConnectionDriver::Ptr m_dbdrv;
std::tr1::weak_ptr<fwk::NotificationCenter> m_notif_center;
diff --git a/src/engine/db/test_library.cpp b/src/engine/db/test_library.cpp
index 5b03540..15acf8b 100644
--- a/src/engine/db/test_library.cpp
+++ b/src/engine/db/test_library.cpp
@@ -35,30 +35,30 @@
int test_main(int, char *[])
{
Gio::init();
- db::Library lib("./", fwk::NotificationCenter::Ptr());
+ db::Library lib("./", fwk::NotificationCenter::Ptr());
- BOOST_CHECK(lib.checkDatabaseVersion() == DB_SCHEMA_VERSION);
+ BOOST_CHECK(lib.checkDatabaseVersion() == DB_SCHEMA_VERSION);
- db::IConnectionDriver::Ptr db(lib.dbDriver());
+ db::IConnectionDriver::Ptr db(lib.dbDriver());
db::LibFolder::Ptr folder_added(lib.addFolder("foo"));
BOOST_CHECK(folder_added);
BOOST_CHECK(folder_added->id() > 0);
- db::LibFolder::Ptr f(lib.getFolder("foo"));
- BOOST_CHECK(f);
+ db::LibFolder::Ptr f(lib.getFolder("foo"));
+ BOOST_CHECK(f);
BOOST_CHECK(f->id() == folder_added->id());
- lib.addFolder("bar");
- BOOST_CHECK(lib.getFolder("bar"));
-
- db::LibFolder::ListPtr l( new db::LibFolder::List );
- lib.getAllFolders( l );
- BOOST_CHECK( l->size() == 2 );
+ lib.addFolder("bar");
+ BOOST_CHECK(lib.getFolder("bar"));
+ db::LibFolder::ListPtr l( new db::LibFolder::List );
+ lib.getAllFolders( l );
+ BOOST_CHECK( l->size() == 2 );
+
int file_id = lib.addFile(folder_added->id(), "foo/myfile", false);
BOOST_CHECK(file_id > 0);
-
- BOOST_CHECK(unlink(lib.dbName().string().c_str()) != -1);
- return 0;
+
+ BOOST_CHECK(unlink(lib.dbName().c_str()) != -1);
+ return 0;
}
/*
diff --git a/src/engine/library/Makefile.am b/src/engine/library/Makefile.am
index c6119c7..ca889e6 100644
--- a/src/engine/library/Makefile.am
+++ b/src/engine/library/Makefile.am
@@ -12,7 +12,7 @@ TEST_LIBS = \
$(top_builddir)/src/fwk/utils/libniepceutils.a \
$(top_builddir)/src/fwk/toolkit/libniepceframework.a \
@BOOST_UNIT_TEST_FRAMEWORK_LIBS@ \
- @LIBGLIBMM_LIBS@ @BOOST_FILESYSTEM_LIBS@ \
+ @LIBGLIBMM_LIBS@ \
@LIBGTKMM_LIBS@ @SQLITE3_LIBS@ @OPENRAW_LIBS@
noinst_LIBRARIES = libniepcelibrary.a
diff --git a/src/engine/library/commands.cpp b/src/engine/library/commands.cpp
index 7638e8b..938af4f 100644
--- a/src/engine/library/commands.cpp
+++ b/src/engine/library/commands.cpp
@@ -22,7 +22,6 @@
#include <boost/any.hpp>
#include <boost/bind.hpp>
-#include <boost/filesystem/path.hpp>
#include "fwk/utils/boost.hpp"
@@ -36,8 +35,6 @@
#include "engine/db/label.hpp"
#include "commands.hpp"
-namespace bfs = boost::filesystem;
-
using db::Library;
using db::LibFolder;
using db::LibFile;
@@ -66,7 +63,7 @@ void Commands::cmdListAllFolders(const Library::Ptr & lib)
}
void Commands::cmdImportFiles(const Library::Ptr & lib,
- const bfs::path & folder,
+ const std::string & folder,
const FileList::Ptr & files, bool manage)
{
DBG_ASSERT(!manage, "managing file is currently unsupported");
diff --git a/src/engine/library/commands.hpp b/src/engine/library/commands.hpp
index 91cfb2e..4010c7e 100644
--- a/src/engine/library/commands.hpp
+++ b/src/engine/library/commands.hpp
@@ -40,7 +40,7 @@ public:
static void cmdListAllFolders(const db::Library::Ptr & lib);
static void cmdListAllKeywords(const db::Library::Ptr & lib);
static void cmdImportFiles(const db::Library::Ptr & lib,
- const boost::filesystem::path & folder,
+ const std::string & folder,
const utils::FileList::Ptr & files,
bool manage);
static void cmdQueryFolderContent(const db::Library::Ptr & lib,
diff --git a/src/engine/library/thumbnailcache.cpp b/src/engine/library/thumbnailcache.cpp
index deb9c3b..ff49c10 100644
--- a/src/engine/library/thumbnailcache.cpp
+++ b/src/engine/library/thumbnailcache.cpp
@@ -37,7 +37,7 @@ using db::LibFile;
namespace library {
- ThumbnailCache::ThumbnailCache(const boost::filesystem::path & dir,
+ ThumbnailCache::ThumbnailCache(const std::string & dir,
const fwk::NotificationCenter::Ptr & nc)
: m_cacheDir(dir),
m_notif_center(nc)
@@ -65,11 +65,11 @@ namespace library {
void ThumbnailCache::execute(const ThumbnailTask::Ptr & task)
{
- const char *filename = task->file()->path().string().c_str();
- DBG_OUT("creating thumbnail for %s",filename);
- int w, h;
- w = task->width();
- h = task->height();
+ const std::string & filename = task->file()->path();
+ DBG_OUT("creating thumbnail for %s",filename.c_str());
+ int w, h;
+ w = task->width();
+ h = task->height();
fwk::MimeType mime_type(filename);
@@ -77,7 +77,7 @@ namespace library {
DBG_OUT("MIME type %s", mime_type.string().c_str());
if(mime_type.isUnknown()) {
- DBG_OUT("unknown file type", filename);
+ DBG_OUT("unknown file type", filename.c_str());
return;
}
if(!mime_type.isImage()) {
@@ -100,7 +100,7 @@ namespace library {
}
}
else {
- GdkPixbuf *pixbuf = or_gdkpixbuf_extract_rotated_thumbnail(filename,
+ GdkPixbuf *pixbuf = or_gdkpixbuf_extract_rotated_thumbnail(filename.c_str(),
std::min(w, h));
if(pixbuf) {
pix = Glib::wrap(pixbuf, true); // take ownership
@@ -127,7 +127,7 @@ namespace library {
}
else
{
- DBG_OUT("couldn't get the thumbnail for %s", filename);
+ DBG_OUT("couldn't get the thumbnail for %s", filename.c_str());
}
}
diff --git a/src/engine/library/thumbnailcache.hpp b/src/engine/library/thumbnailcache.hpp
index f0ecd08..354d254 100644
--- a/src/engine/library/thumbnailcache.hpp
+++ b/src/engine/library/thumbnailcache.hpp
@@ -21,7 +21,6 @@
#ifndef _LIBRARY_THUMBNAILCACHE_H__
#define _LIBRARY_THUMBNAILCACHE_H__
-#include <boost/filesystem/path.hpp>
#include <tr1/memory>
#include "fwk/utils/worker.hpp"
@@ -57,7 +56,7 @@ namespace library {
: private utils::Worker< ThumbnailTask::Ptr >
{
public:
- ThumbnailCache(const boost::filesystem::path & dir,
+ ThumbnailCache(const std::string & dir,
const fwk::NotificationCenter::Ptr & nc);
~ThumbnailCache();
@@ -67,7 +66,7 @@ namespace library {
protected:
virtual void execute(const ThumbnailTask::Ptr & task);
private:
- boost::filesystem::path m_cacheDir;
+ std::string m_cacheDir;
std::tr1::weak_ptr<fwk::NotificationCenter> m_notif_center;
};
diff --git a/src/fwk/toolkit/application.cpp b/src/fwk/toolkit/application.cpp
index a2871cb..f5712dc 100644
--- a/src/fwk/toolkit/application.cpp
+++ b/src/fwk/toolkit/application.cpp
@@ -22,6 +22,7 @@
#include <boost/lexical_cast.hpp>
#include <glibmm/i18n.h>
+#include <giomm/init.h>
#include <gtkmm/main.h>
#include <gtkmm/aboutdialog.h>
#include <gtkmm/rc.h>
@@ -115,6 +116,7 @@ int Application::main(boost::function<Application::Ptr (void)> constructor,
DBG_OUT("thread init");
Glib::thread_init();
}
+ Gio::init();
Gtk::Main kit(argc, argv);
Application::Ptr app = constructor();
diff --git a/src/fwk/toolkit/imageloader.cpp b/src/fwk/toolkit/imageloader.cpp
index 1ca7bda..4562fb5 100644
--- a/src/fwk/toolkit/imageloader.cpp
+++ b/src/fwk/toolkit/imageloader.cpp
@@ -17,8 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-
+#include <giomm/inputstream.h>
+#include <giomm/file.h>
#include <gdkmm/pixbufloader.h>
#include "imageloader.hpp"
@@ -26,7 +26,7 @@
namespace fwk {
-ImageLoader::ImageLoader(const boost::filesystem::path & file)
+ImageLoader::ImageLoader(const std::string & file)
: m_file(file)
{
}
@@ -34,24 +34,25 @@ ImageLoader::ImageLoader(const boost::filesystem::path & file)
Glib::RefPtr<Gdk::Pixbuf> ImageLoader::get_pixbuf()
{
// TODO split get_pixbuf and the real load.
- fwk::MimeType mime_type(m_file.string());
+ fwk::MimeType mime_type(m_file);
Glib::RefPtr<Gdk::PixbufLoader> loader =
- Gdk::PixbufLoader::create(mime_type.string(), true);
+ Gdk::PixbufLoader::create(mime_type.string(), true);
// TODO this code is ugly.
- FILE * f = fopen(m_file.string().c_str(), "rb");
- if(f) {
- size_t byte_read;
- guint8 buffer[128*1024];
- do {
- byte_read = fread((void*)buffer, 1, 128*1024, f);
- if(byte_read) {
- loader->write(buffer, byte_read);
- }
- } while(byte_read);
+ Glib::RefPtr<Gio::File> f = Gio::File::create_for_path(m_file);
+ Glib::RefPtr<Gio::FileInputStream> stream = f->read();
+ if(f) {
+ size_t byte_read;
+ guint8 buffer[128*1024];
+ do {
+ byte_read = stream->read((void*)buffer, 128*1024);
+ if(byte_read) {
+ loader->write(buffer, byte_read);
+ }
+ } while(byte_read);
}
- loader->close();
+ loader->close();
return loader->get_pixbuf();
}
@@ -59,3 +60,12 @@ Glib::RefPtr<Gdk::Pixbuf> ImageLoader::get_pixbuf()
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
diff --git a/src/fwk/toolkit/imageloader.hpp b/src/fwk/toolkit/imageloader.hpp
index 644e484..0bc2d11 100644
--- a/src/fwk/toolkit/imageloader.hpp
+++ b/src/fwk/toolkit/imageloader.hpp
@@ -1,7 +1,7 @@
/*
- * niepce - fwk/imageloader.h
+ * niepce - fwk/imageloader.hpp
*
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
#ifndef __FWK_IMAGELOADER_H__
#define __FWK_IMAGELOADER_H__
-#include <boost/filesystem/path.hpp>
+#include <string>
#include <gdkmm/pixbuf.h>
@@ -30,12 +30,22 @@ namespace fwk {
class ImageLoader
{
public:
- ImageLoader(const boost::filesystem::path & file);
+ ImageLoader(const std::string & file);
Glib::RefPtr<Gdk::Pixbuf> get_pixbuf();
private:
- boost::filesystem::path m_file;
+ std::string m_file;
};
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
+
#endif
diff --git a/src/fwk/toolkit/mimetype.cpp b/src/fwk/toolkit/mimetype.cpp
index 61e849f..b74cdf0 100644
--- a/src/fwk/toolkit/mimetype.cpp
+++ b/src/fwk/toolkit/mimetype.cpp
@@ -18,13 +18,12 @@
*/
#include <string>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/convenience.hpp>
#include <giomm/contenttype.h>
#include "config.h"
#include "fwk/utils/debug.hpp"
+#include "fwk/utils/pathutils.hpp"
#include "mimetype.hpp"
namespace fwk {
@@ -75,13 +74,7 @@ bool MimeType::isUnknown() const
bool MimeType::isXmp() const
{
- boost::filesystem::path path = m_name;
-
-#if BOOST_VERSION >= 103600
- return path.extension() == ".xmp";
-#else
- return extension(path) == ".xmp";
-#endif
+ return fwk::path_extension(m_name) == ".xmp";
}
}
diff --git a/src/fwk/utils/Makefile.am b/src/fwk/utils/Makefile.am
index cb210d9..db66e36 100644
--- a/src/fwk/utils/Makefile.am
+++ b/src/fwk/utils/Makefile.am
@@ -5,11 +5,13 @@ INCLUDES = -I$(top_srcdir)/src/ @LIBGLIBMM_CFLAGS@ \
@EXEMPI_CFLAGS@ @LIBXML2_CFLAGS@
TESTS = testmoniker testfiles testgeometry testxmp \
+ testpathutils \
teststringutils test_db test_db2 test_db3 test_db4 testufrawmeta
EXTRA_DIST = test.xmp test2.ufraw
check_PROGRAMS = testmoniker testfiles testgeometry testxmp \
+ testpathutils \
teststringutils test_db test_db2 test_db3 test_db4 testufrawmeta
testmoniker_SOURCES = testmoniker.cpp
@@ -18,7 +20,7 @@ testmoniker_LDADD = libniepceutils.a \
testfiles_SOURCES = testfiles.cpp
testfiles_LDADD = libniepceutils.a \
- @BOOST_FILESYSTEM_LIBS@ @LIBGLIBMM_LIBS@
+ @LIBGLIBMM_LIBS@
testgeometry_SOURCES = testgeometry.cpp
testgeometry_LDADD = libniepceutils.a \
@@ -26,17 +28,22 @@ testgeometry_LDADD = libniepceutils.a \
testxmp_SOURCES = testxmp.cpp
testxmp_LDADD = libniepceutils.a \
- @EXEMPI_LIBS@ @BOOST_FILESYSTEM_LIBS@ @LIBGLIBMM_LIBS@
+ @EXEMPI_LIBS@ @LIBGLIBMM_LIBS@
testufrawmeta_SOURCES = testufrawmeta.cpp
testufrawmeta_CXXFLAGS = -g -O0
testufrawmeta_LDADD = libniepceutils.a \
- @EXEMPI_LIBS@ @BOOST_FILESYSTEM_LIBS@ @LIBXML2_LIBS@ \
+ @EXEMPI_LIBS@ @LIBXML2_LIBS@ \
@LIBGLIBMM_LIBS@
teststringutils_SOURCES = teststringutils.cpp
teststringutils_LDADD =
+testpathutils_SOURCES = t/testpathutils.cpp
+testpathutils_LDADD = libniepceutils.a \
+ @LIBGLIBMM_LIBS@
+
+
test_db_SOURCES = db/test_db.cpp
test_db_LDADD = libniepceutils.a \
@LIBGLIBMM_LIBS \
@@ -72,6 +79,7 @@ libniepceutils_a_SOURCES = exception.hpp exception.cpp \
files.hpp files.cpp \
geometry.hpp geometry.cpp \
thread.hpp thread.cpp worker.hpp \
+ pathutils.hpp pathutils.cpp \
databinder.hpp databinder.cpp \
db/iconnectiondriver.hpp db/iconnectionmanagerdriver.hpp \
db/insertstatement.cpp db/insertstatement.hpp \
diff --git a/src/fwk/utils/exempi.cpp b/src/fwk/utils/exempi.cpp
index c107c9d..a1dcbf6 100644
--- a/src/fwk/utils/exempi.cpp
+++ b/src/fwk/utils/exempi.cpp
@@ -18,20 +18,20 @@
*/
-#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <boost/filesystem/convenience.hpp>
#include <boost/lexical_cast.hpp>
+#include <glib.h>
+#include <giomm/file.h>
+
#include <exempi/xmp.h>
#include <exempi/xmpconsts.h>
#include "debug.hpp"
#include "exempi.hpp"
-
-namespace bfs = boost::filesystem;
+#include "pathutils.hpp"
namespace xmp {
@@ -79,14 +79,14 @@ XmpMeta::XmpMeta()
* @param sidecar_only we only want the sidecar.
* It will locate the XMP sidecar for the file.
*/
-XmpMeta::XmpMeta(const bfs::path & file, bool sidecar_only)
+XmpMeta::XmpMeta(const std::string & file, bool sidecar_only)
: m_xmp(NULL),
m_keyword_fetched(false)
{
if(!sidecar_only) {
DBG_OUT("trying to load the XMP from the file");
xmp::ScopedPtr<XmpFilePtr>
- xmpfile(xmp_files_open_new(file.string().c_str(), XMP_OPEN_READ));
+ xmpfile(xmp_files_open_new(file.c_str(), XMP_OPEN_READ));
if(xmpfile != NULL) {
m_xmp = xmp_files_get_new_xmp(xmpfile);
if(xmpfile == NULL) {
@@ -96,27 +96,26 @@ XmpMeta::XmpMeta(const bfs::path & file, bool sidecar_only)
}
if(m_xmp == NULL) {
- size_t len;
- char * buffer;
- bfs::path sidecar = file.branch_path()
- / (basename(file) + ".xmp");
-
- DBG_OUT("creating xmpmeta from %s", sidecar.string().c_str());
- FILE * f = fopen(sidecar.string().c_str(), "rb");
+ gsize len = 0;
+ char * buffer = NULL;
+ std::string sidecar = fwk::path_replace_extension(file, ".xmp");
- if (f != NULL) {
- fseek(f, 0, SEEK_END);
- len = ftell(f);
- fseek(f, 0, SEEK_SET);
-
- buffer = (char*)malloc(len + 1);
- /*size_t rlen =*/ fread(buffer, 1, len, f);
+ try {
+ DBG_OUT("creating xmpmeta from %s", sidecar.c_str());
+ Glib::RefPtr<Gio::File> f = Gio::File::create_for_path(sidecar);
+ std::string etag_out;
+ f->load_contents(buffer, len, etag_out);
+ }
+ catch(const Glib::Exception & e) {
+ ERR_OUT("loading XMP failed: %s", e.what().c_str());
+ }
+ if(buffer) {
m_xmp = xmp_new_empty();
if(!xmp_parse(m_xmp, buffer, len)) {
xmp_free(m_xmp);
m_xmp = NULL;
}
- free(buffer);
+ g_free(buffer);
}
}
}
diff --git a/src/fwk/utils/exempi.hpp b/src/fwk/utils/exempi.hpp
index e28d40d..7db7d41 100644
--- a/src/fwk/utils/exempi.hpp
+++ b/src/fwk/utils/exempi.hpp
@@ -24,7 +24,6 @@
#include <vector>
#include <string>
-#include <boost/filesystem/path.hpp>
#include <boost/noncopyable.hpp>
#include <exempi/xmp.h>
@@ -126,7 +125,7 @@ class XmpMeta
{
public:
XmpMeta();
- XmpMeta(const boost::filesystem::path & for_file, bool sidecar_only);
+ XmpMeta(const std::string & for_file, bool sidecar_only);
virtual ~XmpMeta();
bool isOk() const
diff --git a/src/fwk/utils/files.cpp b/src/fwk/utils/files.cpp
index 09891e1..a53c9ac 100644
--- a/src/fwk/utils/files.cpp
+++ b/src/fwk/utils/files.cpp
@@ -17,27 +17,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/convenience.hpp>
#include <boost/algorithm/string.hpp>
+#include <giomm/file.h>
+
#include "debug.hpp"
#include "files.hpp"
+#include "pathutils.hpp"
-namespace bfs = boost::filesystem;
namespace utils {
- bool filter_none(const boost::filesystem::path & )
+ bool filter_none(const Glib::RefPtr<Gio::FileInfo> & )
{
return true;
}
- bool filter_xmp_out(const bfs::path & file)
+ bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file)
{
- std::string ext = extension(file);
+ std::string ext = fwk::path_extension(file->get_name());
boost::to_lower(ext);
if(ext == ".xmp") {
return false;
@@ -51,33 +50,41 @@ namespace utils {
{
}
- FileList::Ptr FileList::getFilesFromDirectory(const FileList::value_type & p, boost::function<bool (const value_type &)> filter)
+ FileList::Ptr FileList::getFilesFromDirectory(const FileList::value_type & p, boost::function<bool (const Glib::RefPtr<Gio::FileInfo> &)> filter)
{
- if(!exists( p ) ) {
- DBG_OUT( "directory %s do not exist", p.string().c_str() );
- return Ptr();
- }
+// if(!exists( p ) ) {
+// DBG_OUT( "directory %s do not exist", p.c_str() );
+// return Ptr();
+// }
try
{
FileList::Ptr l( new FileList() );
- bfs::directory_iterator end_itr;
- for ( bfs::directory_iterator itr( p );
- itr != end_itr;
- ++itr )
+ Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(p);
+ Glib::RefPtr<Gio::FileEnumerator> enumerator = dir->enumerate_children();
+
+ for( Glib::RefPtr<Gio::FileInfo> itr = enumerator->next_file();
+ itr ; itr = enumerator->next_file() )
{
- if ( !is_directory(*itr) )
+ Gio::FileType ftype = itr->get_file_type();
+ if ((ftype == Gio::FILE_TYPE_REGULAR) || (ftype == Gio::FILE_TYPE_SYMBOLIC_LINK))
{
- if( filter(*itr) ) {
- l->push_back(*itr);
- DBG_OUT( "found file %s", itr->string().c_str() );
+ if( filter(itr) ) {
+ std::string fullname = Glib::build_filename(dir->get_path(), itr->get_name());
+ l->push_back(fullname);
+ DBG_OUT( "found file %s", fullname.c_str() );
}
}
}
+ enumerator->close();
l->sort();
return l;
}
- catch( std::exception & e )
+ catch(const Glib::Error & e)
+ {
+ ERR_OUT( "Exception: %s", e.what().c_str() );
+ }
+ catch(const std::exception & e )
{
ERR_OUT( "Exception: %s", e.what() );
}
diff --git a/src/fwk/utils/files.hpp b/src/fwk/utils/files.hpp
index e805a4d..512b7d5 100644
--- a/src/fwk/utils/files.hpp
+++ b/src/fwk/utils/files.hpp
@@ -28,20 +28,21 @@
#include <tr1/memory>
#include <boost/function.hpp>
-#include <boost/filesystem/path.hpp>
+
+#include <giomm/fileinfo.h>
namespace utils {
- bool filter_none(const boost::filesystem::path & file);
- bool filter_xmp_out(const boost::filesystem::path & file);
+ bool filter_none(const Glib::RefPtr<Gio::FileInfo> & file);
+ bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file);
class FileList
- : private std::list< boost::filesystem::path >
+ : private std::list< std::string >
{
public:
typedef std::tr1::shared_ptr< FileList > Ptr;
- typedef std::list< boost::filesystem::path > _impltype_t;
+ typedef std::list< std::string > _impltype_t;
typedef _impltype_t::value_type value_type;
typedef _impltype_t::iterator iterator;
typedef _impltype_t::const_iterator const_iterator;
@@ -52,7 +53,7 @@ namespace utils {
FileList( const _impltype_t & );
static Ptr getFilesFromDirectory(const value_type & dir,
- boost::function<bool (const value_type &)> filter);
+ boost::function<bool (const Glib::RefPtr<Gio::FileInfo> &)> filter);
const_iterator begin() const
{ return _impltype_t::begin(); }
diff --git a/src/fwk/utils/fsutils.hpp b/src/fwk/utils/fsutils.hpp
index 0d42b5c..7d3d003 100644
--- a/src/fwk/utils/fsutils.hpp
+++ b/src/fwk/utils/fsutils.hpp
@@ -21,8 +21,8 @@
#define __UTILS_FSUTILS_H__
#include <string>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
+
+#include "fwk/utils/pathutils.hpp"
namespace utils {
@@ -35,7 +35,7 @@ public:
}
~DirectoryDisposer()
{
- boost::filesystem::remove_all(m_dir);
+ fwk::path_remove_recursive(m_dir);
}
private:
std::string m_dir;
diff --git a/src/fwk/utils/pathutils.cpp b/src/fwk/utils/pathutils.cpp
new file mode 100644
index 0000000..357282e
--- /dev/null
+++ b/src/fwk/utils/pathutils.cpp
@@ -0,0 +1,139 @@
+/*
+ * niepce - fwk/utils/pathutils.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <giomm/file.h>
+
+#include "pathutils.hpp"
+
+namespace fwk {
+
+/** return the basename of a path. Example:
+ /foo/bar/baz.txt returns baz.txt
+ */
+std::string path_basename(const std::string & path)
+{
+ std::string::size_type slash_idx = path.find_last_of("/");
+ if(slash_idx == std::string::npos) {
+ return path;
+ }
+ return std::string(path.begin() + slash_idx + 1, path.end());
+}
+
+static
+std::string::size_type _path_extension_pos(const std::string &path)
+{
+ std::string::size_type idx = path.find_last_of(".");
+ if(idx == std::string::npos) {
+ return std::string::npos;
+ }
+ std::string::size_type slash_idx = path.find_last_of("/");
+ // if the '.' is not part of the last component
+ if(idx < slash_idx) {
+ return std::string::npos;
+ }
+
+ return idx;
+}
+
+/** return the stem of a path, ie basename minus extension
+ /foo/bar/baz.txt returns /foo/bar/baz
+ */
+std::string path_stem(const std::string & path)
+{
+ std::string stem;
+ std::string::size_type idx;
+ idx = _path_extension_pos(path);
+ if(idx == std::string::npos) {
+ return path;
+ }
+ return std::string(path.begin(), path.begin() + idx);
+}
+
+
+/** return the extension of a path
+ /foo/bar/baz.txt returns .txt
+ It always return the "." if any. No extension = "".
+ */
+std::string path_extension(const std::string & path)
+{
+ std::string extension;
+ std::string::size_type idx = _path_extension_pos(path);
+ if(idx != std::string::npos) {
+ extension = std::string(path.begin() + idx, path.end());
+ }
+
+ return extension;
+}
+
+
+std::string path_replace_extension(const std::string & path, const char * ext)
+{
+ std::string result = path;
+ std::string::size_type idx = _path_extension_pos(result);
+ if(idx != std::string::npos) {
+ result.replace(result.begin() + idx, result.end(), ext);
+ }
+ return result;
+}
+
+bool path_exists(const std::string & path)
+{
+ Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(path);
+ return file->query_exists();
+}
+
+
+void _path_remove_recursive(const Glib::RefPtr<Gio::File> & dir)
+{
+ Glib::RefPtr<Gio::FileEnumerator> enumerator = dir->enumerate_children();
+ Glib::RefPtr<Gio::FileInfo> file_info;
+ while(file_info = enumerator->next_file()) {
+ Glib::RefPtr<Gio::File> child;
+ child = dir->get_child(file_info->get_name());
+ if(file_info->get_type() == Gio::FILE_TYPE_DIRECTORY) {
+ _path_remove_recursive(child);
+ }
+ child->remove();
+ }
+}
+
+
+void path_remove_recursive(const std::string & path)
+{
+ Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(path);
+ _path_remove_recursive(dir);
+ dir->remove();
+}
+
+
+
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+
diff --git a/src/fwk/utils/pathutils.hpp b/src/fwk/utils/pathutils.hpp
new file mode 100644
index 0000000..4dd0a59
--- /dev/null
+++ b/src/fwk/utils/pathutils.hpp
@@ -0,0 +1,65 @@
+/*
+ * niepce - fwk/utils/pathutils.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#ifndef __FWK_PATHUTILS_HPP_
+#define __FWK_PATHUTILS_HPP_
+
+#include <string>
+
+namespace fwk {
+
+/** return the basename of a path. Example:
+ /foo/bar/baz.txt returns baz.txt
+ */
+std::string path_basename(const std::string & path);
+
+/** return the stem of a path, ie basename minus extension
+ /foo/bar/baz.txt returns baz
+ */
+std::string path_stem(const std::string & path);
+
+
+/** return the extension of a path
+ /foo/bar/baz.txt returns .txt
+ It always return the "." if any. No extension = "".
+ */
+std::string path_extension(const std::string & path);
+
+std::string path_replace_extension(const std::string & path, const char * ext);
+
+
+bool path_exists(const std::string & path);
+
+void path_remove_recursive(const std::string & path);
+
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+#endif
diff --git a/src/fwk/utils/t/testpathutils.cpp b/src/fwk/utils/t/testpathutils.cpp
new file mode 100644
index 0000000..ee0ca71
--- /dev/null
+++ b/src/fwk/utils/t/testpathutils.cpp
@@ -0,0 +1,41 @@
+/*
+ * niepce - utils/testpathutils.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#include <boost/test/minimal.hpp>
+
+#include <string>
+
+
+#include "pathutils.hpp"
+
+int test_main( int, char *[] ) // note the name!
+{
+ BOOST_CHECK(fwk::path_basename("/foo/bar/baz.txt") == "baz.txt");
+
+ BOOST_CHECK(fwk::path_stem("/foo/bar/baz.txt") == "/foo/bar/baz");
+
+ BOOST_CHECK(fwk::path_extension("/foo/bar/baz.txt") == ".txt");
+
+ BOOST_CHECK(fwk::path_replace_extension("/foo/bar/baz.txt", ".xmp") == "/foo/bar/baz.xmp");
+
+ return 0;
+}
+
diff --git a/src/fwk/utils/testfiles.cpp b/src/fwk/utils/testfiles.cpp
index a85a202..91f1f42 100644
--- a/src/fwk/utils/testfiles.cpp
+++ b/src/fwk/utils/testfiles.cpp
@@ -23,12 +23,17 @@
#include <stdlib.h>
+#include <giomm/init.h>
+#include <glibmm/init.h>
+
#include "files.hpp"
using utils::FileList;
int test_main( int, char *[] ) // note the name!
{
+ Glib::init();
+ Gio::init();
system( "mkdir -p AAtest/sub" );
system( "touch AAtest/1" );
system( "touch AAtest/2" );
diff --git a/src/fwk/utils/testufrawmeta.cpp b/src/fwk/utils/testufrawmeta.cpp
index 594b83c..0d918f2 100644
--- a/src/fwk/utils/testufrawmeta.cpp
+++ b/src/fwk/utils/testufrawmeta.cpp
@@ -21,17 +21,21 @@
#include <boost/test/minimal.hpp>
#include <stdlib.h>
+#include <string>
#include <vector>
#include <exempi/xmpconsts.h>
+#include <giomm/init.h>
+
#include "debug.hpp"
#include "exempi.hpp"
#include "ufrawmeta.hpp"
int test_main( int, char *[] ) // note the name!
{
- boost::filesystem::path dir;
+ Gio::init();
+ std::string dir;
const char * pdir = getenv("srcdir");
if(pdir == NULL) {
dir = ".";
@@ -41,13 +45,13 @@ int test_main( int, char *[] ) // note the name!
}
utils::ExempiManager xmpManager(NULL);
- xmp::ScopedPtr<XmpPtr> xmp(xmp_new_empty());
+ xmp::ScopedPtr<XmpPtr> xmp(xmp_new_empty());
- utils::UfrawMeta ufraw(dir / "test2.ufraw");
+ utils::UfrawMeta ufraw(dir + "/test2.ufraw");
BOOST_CHECK(ufraw.ufraw_to_xmp(xmp));
- xmp::ScopedPtr<XmpStringPtr> property(xmp_string_new());
+ xmp::ScopedPtr<XmpStringPtr> property(xmp_string_new());
BOOST_CHECK(property != NULL);
BOOST_CHECK(xmp_get_property(xmp, NS_CAMERA_RAW_SETTINGS,
"WhiteBalance", property, NULL));
diff --git a/src/fwk/utils/testxmp.cpp b/src/fwk/utils/testxmp.cpp
index 82c6710..d59c202 100644
--- a/src/fwk/utils/testxmp.cpp
+++ b/src/fwk/utils/testxmp.cpp
@@ -23,11 +23,15 @@
#include <stdlib.h>
#include <vector>
+#include <glibmm/init.h>
+
#include "exempi.hpp"
int test_main( int, char *[] ) // note the name!
{
- boost::filesystem::path dir;
+ Glib::init();
+
+ std::string dir;
const char * pdir = getenv("srcdir");
if(pdir == NULL) {
dir = ".";
@@ -37,7 +41,7 @@ int test_main( int, char *[] ) // note the name!
}
utils::ExempiManager xmpManager;
- utils::XmpMeta meta(dir / "test.xmp", true);
+ utils::XmpMeta meta(dir + "/test.xmp", true);
BOOST_CHECK(meta.isOk());
BOOST_CHECK(meta.orientation() == 1);
const std::vector< std::string > & keywords(meta.keywords());
diff --git a/src/fwk/utils/ufrawmeta.cpp b/src/fwk/utils/ufrawmeta.cpp
index d84b0ed..11e0509 100644
--- a/src/fwk/utils/ufrawmeta.cpp
+++ b/src/fwk/utils/ufrawmeta.cpp
@@ -21,7 +21,6 @@
#include <vector>
#include <utility>
-#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/lexical_cast.hpp>
@@ -31,10 +30,9 @@
#include "debug.hpp"
#include "ufrawmeta.hpp"
#include "exempi.hpp"
+#include "pathutils.hpp"
-namespace bfs = boost::filesystem;
-
namespace utils {
static const struct string_pair_t {
@@ -91,7 +89,7 @@ namespace utils {
};
- UfrawMeta::UfrawMeta(const bfs::path & file)
+ UfrawMeta::UfrawMeta(const std::string & file)
: m_id_file(file),
m_hasSettings(false),
m_startDepth(-1)
@@ -315,9 +313,9 @@ namespace utils {
bool UfrawMeta::ufraw_to_xmp(XmpPtr xmp)
{
bool has_data = false;
- if(exists(m_id_file)) {
+ if(fwk::path_exists(m_id_file)) {
xmlTextReaderPtr reader;
- reader = xmlNewTextReaderFilename(m_id_file.string().c_str());
+ reader = xmlNewTextReaderFilename(m_id_file.c_str());
if(reader != NULL) {
int ret = xmlTextReaderRead(reader);
while(ret == 1) {
@@ -334,7 +332,7 @@ namespace utils {
}
}
else {
- DBG_OUT("file not found %s", m_id_file.string().c_str());
+ DBG_OUT("file not found %s", m_id_file.c_str());
}
if(has_data) {
xmp_set_property_bool(xmp, xmp::UFRAW_INTEROP_NAMESPACE,
diff --git a/src/fwk/utils/ufrawmeta.hpp b/src/fwk/utils/ufrawmeta.hpp
index cd347bc..5eff6f5 100644
--- a/src/fwk/utils/ufrawmeta.hpp
+++ b/src/fwk/utils/ufrawmeta.hpp
@@ -22,14 +22,12 @@
#include <exempi/xmp.h>
#include <libxml/xmlreader.h>
-#include <boost/filesystem/path.hpp>
-
namespace utils {
class UfrawMeta
{
public:
- UfrawMeta(const boost::filesystem::path & file);
+ UfrawMeta(const std::string & file);
/** convert the .ufraw file to a XMP meta. Scrap the Exif
* @param file the name of the ufraw filename.
@@ -41,7 +39,7 @@ namespace utils {
static int get_tag_id(const xmlChar *name);
bool ufraw_process_xml_node(xmlTextReaderPtr reader, XmpPtr xmp);
- boost::filesystem::path m_id_file; /**< the ufraw ID file */
+ std::string m_id_file; /**< the ufraw ID file */
std::string m_input;
std::string m_output;
diff --git a/src/libraryclient/Makefile.am b/src/libraryclient/Makefile.am
index d951d4d..bc569de 100644
--- a/src/libraryclient/Makefile.am
+++ b/src/libraryclient/Makefile.am
@@ -14,7 +14,7 @@ TEST_LIBS = \
$(top_builddir)/src/fwk/toolkit/libniepceframework.a \
$(top_builddir)/src/fwk/libfwk.a \
@BOOST_UNIT_TEST_FRAMEWORK_LIBS@ \
- @LIBGLIBMM_LIBS@ @BOOST_FILESYSTEM_LIBS@ \
+ @LIBGLIBMM_LIBS@ \
@LIBGTKMM_LIBS@ @SQLITE3_LIBS@ @OPENRAW_LIBS@ \
@EXEMPI_LIBS@
diff --git a/src/libraryclient/libraryclient.cpp b/src/libraryclient/libraryclient.cpp
index baca875..3254654 100644
--- a/src/libraryclient/libraryclient.cpp
+++ b/src/libraryclient/libraryclient.cpp
@@ -17,7 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <boost/filesystem/path.hpp>
#include "fwk/utils/moniker.hpp"
@@ -26,7 +25,6 @@
using library::tid_t;
-namespace bfs = boost::filesystem;
namespace libraryclient {
@@ -35,7 +33,7 @@ const char * s_thumbcacheDirname = "thumbcache";
LibraryClient::LibraryClient(const utils::Moniker & moniker,
const fwk::NotificationCenter::Ptr & nc)
: m_pImpl(ClientImpl::makeClientImpl(moniker, nc)),
- m_thumbnailCache(bfs::path(moniker.path()) / s_thumbcacheDirname, nc)
+ m_thumbnailCache(moniker.path() + "/" + s_thumbcacheDirname, nc)
{
}
diff --git a/src/libraryclient/test_worker.cpp b/src/libraryclient/test_worker.cpp
index 8e9de23..3462c22 100644
--- a/src/libraryclient/test_worker.cpp
+++ b/src/libraryclient/test_worker.cpp
@@ -26,6 +26,7 @@
#include <boost/bind.hpp>
#include <boost/test/minimal.hpp>
+#include <giomm/init.h>
#include <glibmm/thread.h>
using namespace library;
@@ -39,6 +40,7 @@ void foo(const db::Library::Ptr &)
//BOOST_AUTO_TEST_CASE(worker_test)
int test_main(int, char *[])
{
+ Gio::init();
if(!Glib::thread_supported())
Glib::thread_init();
diff --git a/src/ncr/image.cpp b/src/ncr/image.cpp
index 7b1e744..8eb9efc 100644
--- a/src/ncr/image.cpp
+++ b/src/ncr/image.cpp
@@ -60,7 +60,7 @@ Image::~Image()
delete priv;
}
-void Image::reload(const boost::filesystem::path & p, bool is_raw,
+void Image::reload(const std::string & p, bool is_raw,
int orientation)
{
Glib::RefPtr<Gegl::Node> load_file;
@@ -70,12 +70,12 @@ void Image::reload(const boost::filesystem::path & p, bool is_raw,
if(!is_raw) {
load_file = priv->m_node->new_child("operation", "gegl:load");
- load_file->set("path", p.string());
+ load_file->set("path", p);
priv->m_rgb = load_file;
}
else {
ORRawDataRef rawdata;
- or_get_extract_rawdata(p.string().c_str(), 0, &rawdata);
+ or_get_extract_rawdata(p.c_str(), 0, &rawdata);
Glib::RefPtr<Gegl::Buffer> buffer = ncr::load_rawdata(rawdata);
// @todo can return a NULL buffer if load failed. Deal with that.
load_file = priv->m_node->new_child("operation", "gegl:load-buffer");
diff --git a/src/ncr/image.hpp b/src/ncr/image.hpp
index 027fde2..1bad3e5 100644
--- a/src/ncr/image.hpp
+++ b/src/ncr/image.hpp
@@ -24,7 +24,6 @@
#define _NCR_IMAGE_H_
#include <tr1/memory>
-#include <boost/filesystem/path.hpp>
#include <gdkmm/pixbuf.h>
@@ -40,7 +39,7 @@ public:
virtual ~Image();
Glib::RefPtr<Gdk::Pixbuf> pixbuf_for_display();
- void reload(const boost::filesystem::path & p, bool is_raw,
+ void reload(const std::string & p, bool is_raw,
int orientation);
void set_scale(double scale);
diff --git a/src/niepce/Makefile.am b/src/niepce/Makefile.am
index 1fcf387..1d75008 100644
--- a/src/niepce/Makefile.am
+++ b/src/niepce/Makefile.am
@@ -10,7 +10,7 @@ bin_PROGRAMS = niepce
niepce_CPPFLAGS = @LIBGTKMM_CFLAGS@ @GCONF_CFLAGS@ \
-DNIEPCE_LOCALEDIR=\"@NIEPCE_LOCALEDIR \"
-niepce_LDFLAGS = -Wl,--as-needed @BOOST_FILESYSTEM_LDFLAGS@
+niepce_LDFLAGS =
niepce_LDADD = \
$(top_builddir)/src/engine/db/libniepcedb.a \
$(top_builddir)/src/niepce/ui/libniepceui.a \
@@ -28,7 +28,6 @@ niepce_LDADD = \
@LIBGLIBMM_LIBS@ \
@LIBGTKMM_LIBS@ @SQLITE3_LIBS@ \
@GCONF_LIBS@ \
- @BOOST_FILESYSTEM_LIBS@ \
@GOOCANVASMM_LIBS@ @BABL_LIBS@ \
@GEGLMM_LIBS@ @OPENRAW_LIBS@ @EXEMPI_LIBS@
diff --git a/src/niepce/main.cpp b/src/niepce/main.cpp
index e7c9d56..aa59041 100644
--- a/src/niepce/main.cpp
+++ b/src/niepce/main.cpp
@@ -23,7 +23,6 @@
#include "config.h"
#include <boost/bind.hpp>
-#include <boost/filesystem/path.hpp>
#include <glibmm/i18n.h>
#include <glibmm/thread.h>
@@ -32,7 +31,6 @@
#include "xmp.hpp"
#include "ui/niepceapplication.hpp"
-namespace bfs = boost::filesystem;
using utils::ExempiManager;
@@ -42,10 +40,6 @@ int main(int argc, char ** argv)
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
- // we need to init boost::filesystem to use native path checks.
- // note: this is not the case in the tests.
- bfs::path::default_name_check(&bfs::native);
-
ExempiManager ex_manager(niepce::xmp_namespaces);
if(!Glib::thread_supported())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]