MCPcopy Create free account
hub / github.com/acl-dev/acl / cmp_copy

Function cmp_copy

lib_acl_cpp/samples/dircopy/main.cpp:100–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100static bool cmp_copy(acl::scan_dir& scan, const char* name,
101 const acl::string& to_path, int* ncopied)
102{
103 const char* rpath = scan.curr_path();
104 if (rpath == NULL)
105 {
106 logger_error("get current path error: %s, file: %s",
107 acl::last_serror(), name);
108 return false;
109 }
110
111 SKIP(rpath);
112 SKIP(name);
113
114// printf(">>rpath: %s\r\n", rpath);
115// printf(">>name: %s\r\n", name);
116
117 acl::string from_filepath;
118 if (*rpath == 0)
119 from_filepath << name;
120 else
121 from_filepath << rpath << SEP << name;
122
123 if (strstr(from_filepath.c_str(), ".svn") != NULL
124 || strstr(from_filepath.c_str(), ".git") != NULL
125 || strstr(from_filepath.c_str(), ".cvs") != NULL
126 || strstr(from_filepath.c_str(), ".inc") != NULL
127 || strstr(from_filepath.c_str(), ".exe") != NULL
128 || strstr(from_filepath.c_str(), ".zip") != NULL
129 || strstr(from_filepath.c_str(), ".rar") != NULL
130 || strstr(from_filepath.c_str(), ".tar") != NULL
131 || strstr(from_filepath.c_str(), ".tar.gz") != NULL
132 || strstr(from_filepath.c_str(), ".tgz") != NULL
133 || strstr(from_filepath.c_str(), ".bzip2") != NULL
134 || strstr(from_filepath.c_str(), ".o") != NULL)
135 {
136 return true;
137 }
138
139 acl::ifstream from_fp;
140 if (from_fp.open_read(from_filepath.c_str()) == false)
141 {
142 logger_error("open source file: %s error: %s",
143 from_filepath.c_str(), acl::last_serror());
144 return false;
145 }
146
147 acl::string to_pathbuf;
148 acl::string to_filepath;
149 to_pathbuf << to_path << SEP << rpath;
150 to_filepath << to_path << SEP << rpath << SEP << name;
151
152 //printf("from_filepath: %s, to_filepath: %s\r\n",
153 // from_fp.file_path(), to_filepath.c_str());
154
155 acl::ifstream to_fp;
156 if (to_fp.open_read(to_filepath.c_str()) == false)
157 {

Callers 1

do_copyFunction · 0.85

Calls 9

curr_pathMethod · 0.80
fsizeMethod · 0.80
file_pathMethod · 0.80
copy_fileFunction · 0.70
last_serrorFunction · 0.50
c_strMethod · 0.45
open_readMethod · 0.45
closeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…