25#pragma warning (disable : 4018)
26#pragma warning (disable : 4267)
42#include <diff_match_patch.h>
45#pragma warning(default:4018)
46#pragma warning(default:4267)
57 return std::string(
"contexts");
59 return std::string(
"robots");
70 return std::string(
".contexts");
72 return std::string(
".robots");
85 if (fileName[0] ==
'.') {
97 if (source ==
nullptr)
133 fwrite(buf, 1, size, dest);
143 return !yarp::os::impl::unlink(fileName.c_str());
162 int n = yarp::os::impl::scandir(
srcDirName.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
166 std::cerr <<
"Could not read from directory " <<
srcDirName <<
'\n';
189 printf(
"Directory %s already exist; remove it first, or use the diff/merge commands\n",
destDirName.c_str());
199 for (
int i = 0; i<
n; i++)
202 std::string name =
namelist[i]->d_name;
204 if (name !=
"." && name !=
"..")
214 return (ok ==
true ? 0 : -1);
220 if (yarp::os::impl::stat(dirName.c_str(), &
statbuf) == -1)
223 printf(
"Error in checking properties for %s\n", dirName.c_str());
231 int n = yarp::os::impl::scandir(dirName.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
235 printf(
"Could not read from directory %s\n", dirName.c_str());
240 for (
int i = 0; i<
n; i++)
242 std::string name =
namelist[i]->d_name;
243 std::string path = std::string(dirName).append(
PATH_SEPARATOR).append(name);
244 if (name !=
"." && name !=
"..")
262 int n = yarp::os::impl::scandir(
curPath.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
266 for (
int i = 0; i<
n; i++) {
268 std::string name =
namelist[i]->d_name;
269 if (name !=
"." && name !=
"..")
273 if (yarp::os::impl::stat(path.c_str(), &
statbuf) == -1) {
274 printf(
"Error in checking properties for %s\n", path.c_str());
291 int n = yarp::os::impl::scandir(
curPath.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
296 for (
int i = 0; i<
n; i++)
307 if (name !=
"." && name !=
"..")
311 if (yarp::os::impl::stat(path.c_str(), &
statbuf) == -1) {
312 printf(
"Error in checking properties for %s\n", path.c_str());
346 printf(
"**LOCAL USER DATA:\n");
359 printf(
"**SYSADMIN DATA:\n");
372 printf(
"**INSTALLED DATA:\n");
383 yarp::os::impl::DIR*
dir = yarp::os::impl::opendir((yarpdatahome).
c_str());
384 if (
dir !=
nullptr) {
385 yarp::os::impl::closedir(
dir);
391 if (
dir !=
nullptr) {
392 yarp::os::impl::closedir(
dir);
397 if (
dir !=
nullptr) {
398 yarp::os::impl::closedir(
dir);
410 std::string
fname(fileName);
411 if (
fname.find(
'/') == std::string::npos) {
426 std::string strPath = std::string(
basePath);
427 if ((strPath.rfind(
'/') == std::string::npos) || (strPath.rfind(
'/') != strPath.size() - 1)) {
440 int n = yarp::os::impl::scandir(strPath.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
443 std::cerr <<
"Could not read from directory " << strPath <<
'\n';
447 for (
int i = 0; i<
n; i++)
450 std::string name =
namelist[i]->d_name;
452 if (name !=
"." && name !=
"..")
495 std::string
srcStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
498 std::string
destStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
534 std::string
srcStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
537 std::string
destStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
540 std::string
hiddenDestStr((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
586 printf(
"Could not merge automatically, use mergetool\n");
610#ifndef YARP_NO_DEPRECATED
626#ifndef YARP_NO_DEPRECATED
645 for (
size_t i = 2; i<
importArg.size(); ++i)
647 std::string fileName =
importArg.get(i).asString();
690 yError(
"Invalid number of parameters");
695#ifndef YARP_NO_DEPRECATED
702#ifndef YARP_NO_DEPRECATED
720 int n = yarp::os::impl::scandir(
curPath.c_str(), &
namelist,
nullptr, yarp::os::impl::alphasort);
724 for (
int i = 0; i<
n; i++) {
726 std::string name =
namelist[i]->d_name;
728 if (name !=
"." && name !=
"..")
751#ifndef YARP_NO_DEPRECATED
767#ifndef YARP_NO_DEPRECATED
787 printf(
"Are you sure you want to remove this folder: %s ? (y/n): ",
targetPath.c_str());
814 printf(
"Are you sure you want to remove files from this folder: %s ? (y/n): ",
targetPath.c_str());
826 for (
size_t i = 2; i<
removeArg.size(); ++i)
828 std::string fileName =
removeArg.get(i).asString();
856 yError (
"Invalid number of parameters");
862#ifndef YARP_NO_DEPRECATED
869#ifndef YARP_NO_DEPRECATED
891 strcpy(command,
"winmerge ");
898 return std::system(command);
902#ifndef YARP_NO_DEPRECATED
918 std::ostream
tmp(
nullptr);
920#ifndef YARP_NO_DEPRECATED
933 std::cout <<
subDir <<
'\n';
938 printf(
"Exception occurred during call to diffList() on path \"%s\"\n",
userPath.c_str());
946#ifndef YARP_NO_DEPRECATED
962#ifndef YARP_NO_DEPRECATED
971 for (
size_t i = 2; i<
mergeArg.size(); ++i)
973 std::string fileName =
mergeArg.get(i).asString();
988 printf(
"Need to use mergetool\n");
990 printf(
"Could not merge file %s\n", fileName.c_str());
A simple collection of objects that can be described and transmitted in a portable way.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
These options are loosely based on http://wiki.icub.org/wiki/YARP_ResourceFinder.
Helper class for finding config files and other external resources.
std::string findPath(const std::string &name)
Expand a partial path to a full path.
yarp::os::Bottle findPaths(const std::string &name)
Expand a partial path to a list of paths.
bool setQuiet(bool quiet=true)
Request that information be suppressed from the console.
bool setVerbose(bool verbose=true)
Request that information be printed to the console on how resources are being found.
std::string yarpdatahome()
Returns the directory where user-specific YARP data files should be written.
An interface to the operating system, including Port based communication.
int mkdir(const char *p)
Portable wrapper for the mkdir() function.
int stat(const char *path)
Portable wrapper for the stat() function.
int rmdir(const char *p)
Portable wrapper for the rmdir() function.
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
int recursiveMerge(std::string srcDirName, std::string destDirName, std::string commonParentName, std::ostream &output)
bool isHidden(std::string fileName)
int fileMerge(std::string srcFileName, std::string destFileName, std::string commonParentName)
void printSysadmFolders(yarp::os::ResourceFinder &rf, folderType ftype)
int recursiveDiff(std::string srcDirName, std::string destDirName, std::ostream &output)
void prepareHomeFolder(yarp::os::ResourceFinder &rf, folderType ftype)
void printInstalledFolders(yarp::os::ResourceFinder &rf, folderType ftype)
bool recursiveFileList(const char *basePath, const char *suffix, std::set< std::string > &filenames)
void printUserFolders(yarp::os::ResourceFinder &rf, folderType ftype)
void printContentDirs(const std::string &curPath)
std::vector< std::string > listContentDirs(const std::string &curPath)
int remove(yarp::os::Bottle &removeArg, folderType fType, bool verbose)
int diffList(folderType fType, bool verbose)
std::vector< std::string > listContentFiles(const std::string &curPath)
bool fileCopy(std::string srcFileName, std::string destFileName, bool force, bool verbose)
std::string getFolderStringName(folderType ftype)
int diff(std::string contextName, folderType fType, bool verbose)
std::string getFolderStringNameHidden(folderType ftype)
int importAll(folderType fType, bool verbose)
int recursiveCopy(std::string srcDirName, std::string destDirName, bool force, bool verbose)
int recursiveRemove(std::string dirName, bool verbose)
bool prepareSubFolders(const std::string &startDir, const std::string &fileName)
bool fileRemove(std::string fileName)
int merge(yarp::os::Bottle &mergeArg, folderType fType, bool verbose)