Skip to content
Snippets Groups Projects
Commit 2bd51535 authored by Jakob Blomer's avatar Jakob Blomer
Browse files

remove dependency of util/posix.h on shortstring.h

parent 70a0245e
No related branches found
No related tags found
No related merge requests found
...@@ -334,6 +334,7 @@ set (LIBCVMFS_SERVER_SOURCES ...@@ -334,6 +334,7 @@ set (LIBCVMFS_SERVER_SOURCES
sanitizer.cc sanitizer.cc
session_context.cc session_context.cc
signature.cc signature.cc
shortstring.cc
sql.cc sql.cc
sqlitemem.cc sqlitemem.cc
ssl.cc ssl.cc
...@@ -423,6 +424,7 @@ set (CVMFS_SWISSKNIFE_SOURCES ...@@ -423,6 +424,7 @@ set (CVMFS_SWISSKNIFE_SOURCES
session_context.cc session_context.cc
signature.cc signature.cc
signing_tool.cc signing_tool.cc
shortstring.cc
sql.cc sql.cc
sqlitemem.cc sqlitemem.cc
ssl.cc ssl.cc
...@@ -620,6 +622,7 @@ if(BUILD_RECEIVER) ...@@ -620,6 +622,7 @@ if(BUILD_RECEIVER)
session_context.cc session_context.cc
signature.cc signature.cc
signing_tool.cc signing_tool.cc
shortstring.cc
ssl.cc ssl.cc
statistics.cc statistics.cc
statistics_database.cc statistics_database.cc
......
/**
* This file is part of the CernVM File System.
*
* Some common functions.
*/
#include "cvmfs_config.h"
#include "shortstring.h"
#ifdef CVMFS_NAMESPACE_GUARD
namespace CVMFS_NAMESPACE_GUARD {
#endif
PathString GetParentPath(const PathString &path) {
int length = static_cast<int>(path.GetLength());
if (length == 0)
return path;
const char *chars = path.GetChars();
for (int i = length-1; i >= 0; --i) {
if (chars[i] == '/')
return PathString(chars, i);
}
return path;
}
NameString GetFileName(const PathString &path) {
NameString name;
int length = static_cast<int>(path.GetLength());
const char *chars = path.GetChars();
int i;
for (i = length-1; i >= 0; --i) {
if (chars[i] == '/')
break;
}
i++;
if (i < length) {
name.Append(chars+i, length-i);
}
return name;
}
#ifdef CVMFS_NAMESPACE_GUARD
} // namespace CVMFS_NAMESPACE_GUARD
#endif
...@@ -196,6 +196,11 @@ atomic_int64 ShortString<StackSize, Type>::num_overflows_ = 0; ...@@ -196,6 +196,11 @@ atomic_int64 ShortString<StackSize, Type>::num_overflows_ = 0;
template<unsigned char StackSize, char Type> template<unsigned char StackSize, char Type>
atomic_int64 ShortString<StackSize, Type>::num_instances_ = 0; atomic_int64 ShortString<StackSize, Type>::num_instances_ = 0;
// See posix.cc for the std::string counterparts
PathString GetParentPath(const PathString &path);
NameString GetFileName(const PathString &path);
#ifdef CVMFS_NAMESPACE_GUARD #ifdef CVMFS_NAMESPACE_GUARD
} // namespace CVMFS_NAMESPACE_GUARD } // namespace CVMFS_NAMESPACE_GUARD
#endif #endif
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <map> #include <map>
#include <string> #include <string>
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#endif #endif
#include <sys/wait.h> #include <sys/wait.h>
#include <cstring>
#include "util/posix.h" #include "util/posix.h"
#include "util/string.h" #include "util/string.h"
......
...@@ -137,24 +137,6 @@ std::string GetParentPath(const std::string &path) { ...@@ -137,24 +137,6 @@ std::string GetParentPath(const std::string &path) {
} }
/**
* Gets the file name part of a path.
*/
PathString GetParentPath(const PathString &path) {
int length = static_cast<int>(path.GetLength());
if (length == 0)
return path;
const char *chars = path.GetChars();
for (int i = length-1; i >= 0; --i) {
if (chars[i] == '/')
return PathString(chars, i);
}
return path;
}
/** /**
* Gets the file name part of a path. * Gets the file name part of a path.
*/ */
...@@ -168,25 +150,6 @@ std::string GetFileName(const std::string &path) { ...@@ -168,25 +150,6 @@ std::string GetFileName(const std::string &path) {
} }
NameString GetFileName(const PathString &path) {
NameString name;
int length = static_cast<int>(path.GetLength());
const char *chars = path.GetChars();
int i;
for (i = length-1; i >= 0; --i) {
if (chars[i] == '/')
break;
}
i++;
if (i < length) {
name.Append(chars+i, length-i);
}
return name;
}
bool IsAbsolutePath(const std::string &path) { bool IsAbsolutePath(const std::string &path) {
return (!path.empty() && path[0] == '/'); return (!path.empty() && path[0] == '/');
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "shortstring.h"
#include "util/pointer.h" #include "util/pointer.h"
#include "util/single_copy.h" #include "util/single_copy.h"
...@@ -65,9 +64,7 @@ struct LsofEntry { ...@@ -65,9 +64,7 @@ struct LsofEntry {
std::string MakeCanonicalPath(const std::string &path); std::string MakeCanonicalPath(const std::string &path);
std::string GetParentPath(const std::string &path); std::string GetParentPath(const std::string &path);
PathString GetParentPath(const PathString &path);
std::string GetFileName(const std::string &path); std::string GetFileName(const std::string &path);
NameString GetFileName(const PathString &path);
void SplitPath(const std::string &path, void SplitPath(const std::string &path,
std::string *dirname, std::string *dirname,
std::string *filename); std::string *filename);
......
...@@ -6,7 +6,6 @@ set (CVMFS_STRESS_SOURCES ...@@ -6,7 +6,6 @@ set (CVMFS_STRESS_SOURCES
${CVMFS_SOURCE_DIR}/gateway_util.cc ${CVMFS_SOURCE_DIR}/gateway_util.cc
${CVMFS_SOURCE_DIR}/hash.cc ${CVMFS_SOURCE_DIR}/hash.cc
${CVMFS_SOURCE_DIR}/json_document.cc ${CVMFS_SOURCE_DIR}/json_document.cc
${CVMFS_SOURCE_DIR}/logging.cc
${CVMFS_SOURCE_DIR}/options.cc ${CVMFS_SOURCE_DIR}/options.cc
${CVMFS_SOURCE_DIR}/pack.cc ${CVMFS_SOURCE_DIR}/pack.cc
${CVMFS_SOURCE_DIR}/s3fanout.cc ${CVMFS_SOURCE_DIR}/s3fanout.cc
...@@ -22,6 +21,7 @@ set (CVMFS_STRESS_SOURCES ...@@ -22,6 +21,7 @@ set (CVMFS_STRESS_SOURCES
${CVMFS_SOURCE_DIR}/upload_spooler_definition.cc ${CVMFS_SOURCE_DIR}/upload_spooler_definition.cc
${CVMFS_SOURCE_DIR}/util/exception.cc ${CVMFS_SOURCE_DIR}/util/exception.cc
${CVMFS_SOURCE_DIR}/util/file_backed_buffer.cc ${CVMFS_SOURCE_DIR}/util/file_backed_buffer.cc
${CVMFS_SOURCE_DIR}/util/logging.cc
${CVMFS_SOURCE_DIR}/util/mmap_file.cc ${CVMFS_SOURCE_DIR}/util/mmap_file.cc
${CVMFS_SOURCE_DIR}/util/posix.cc ${CVMFS_SOURCE_DIR}/util/posix.cc
${CVMFS_SOURCE_DIR}/util/string.cc ${CVMFS_SOURCE_DIR}/util/string.cc
......
...@@ -230,6 +230,7 @@ set (CVMFS_UNITTEST_SOURCES ...@@ -230,6 +230,7 @@ set (CVMFS_UNITTEST_SOURCES
${CVMFS_SOURCE_DIR}/session_context.cc ${CVMFS_SOURCE_DIR}/session_context.cc
${CVMFS_SOURCE_DIR}/signature.cc ${CVMFS_SOURCE_DIR}/signature.cc
${CVMFS_SOURCE_DIR}/signing_tool.cc ${CVMFS_SOURCE_DIR}/signing_tool.cc
${CVMFS_SOURCE_DIR}/shortstring.cc
${CVMFS_SOURCE_DIR}/sql.cc ${CVMFS_SOURCE_DIR}/sql.cc
${CVMFS_SOURCE_DIR}/sqlitemem.cc ${CVMFS_SOURCE_DIR}/sqlitemem.cc
${CVMFS_SOURCE_DIR}/sqlitevfs.cc ${CVMFS_SOURCE_DIR}/sqlitevfs.cc
...@@ -503,6 +504,7 @@ set (CVMFS_TEST_PUBLISH_SOURCES ...@@ -503,6 +504,7 @@ set (CVMFS_TEST_PUBLISH_SOURCES
${CVMFS_SOURCE_DIR}/sanitizer.cc ${CVMFS_SOURCE_DIR}/sanitizer.cc
${CVMFS_SOURCE_DIR}/session_context.cc ${CVMFS_SOURCE_DIR}/session_context.cc
${CVMFS_SOURCE_DIR}/signature.cc ${CVMFS_SOURCE_DIR}/signature.cc
${CVMFS_SOURCE_DIR}/shortstring.cc
${CVMFS_SOURCE_DIR}/sql.cc ${CVMFS_SOURCE_DIR}/sql.cc
${CVMFS_SOURCE_DIR}/sqlitemem.cc ${CVMFS_SOURCE_DIR}/sqlitemem.cc
${CVMFS_SOURCE_DIR}/ssl.cc ${CVMFS_SOURCE_DIR}/ssl.cc
......
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