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

Method move_file

lib_acl_cpp/src/queue/queue_file.cpp:312–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312bool queue_file::move_file(const char* queueName, const char* extName)
313{
314 acl::string buf(256);
315 bool once_again = false;
316
317 while (true) {
318 buf.clear();
319 buf << m_home << PATH_SEP << queueName << PATH_SEP << m_queueSub
320 << PATH_SEP << m_partName << "." << extName;
321
322#ifdef ACL_WINDOWS
323 // ��win32�±����ȹر��ļ����
324 this->close();
325#endif
326
327 if (rename(m_filePath.c_str(), buf.c_str()) == 0) {
328 break;
329 }
330
331 // ������ش���ԭ����Ŀ��·�������ڣ����Դ���Ŀ¼�ṹ
332
333 if (once_again || acl_last_error() != ENOENT) {
334 logger_error("move from %s to %s error(%s), errno: %d, %d",
335 m_filePath.c_str(), buf.c_str(), last_serror(),
336 last_error(), ENOENT);
337 return false;
338 }
339
340 // �������Ա�־λ
341 once_again = true;
342
343 buf.clear();
344 buf << m_home << PATH_SEP << queueName
345 << PATH_SEP << m_queueSub;
346
347 // ��������Ŀ¼
348 if (acl_make_dirs(buf.c_str(), 0700) == -1) {
349 logger_error("mkdir: %s error(%s)",
350 buf.c_str(), last_serror());
351 return false;
352 }
353 }
354
355#ifdef ACL_WINDOWS
356 // win32 ����Ҫ�����ٴ�
357 return open(m_home, queueName, m_queueSub, m_partName, extName);
358#else
359 if (m_queueName != queueName) {
360 ACL_SAFE_STRNCPY(m_queueName, queueName, sizeof(m_queueName));
361 }
362 if (m_extName != extName) {
363 ACL_SAFE_STRNCPY(m_extName, extName, sizeof(m_extName));
364 }
365 m_filePath.clear();
366 m_filePath << m_home << PATH_SEP << m_queueName << PATH_SEP
367 << m_queueSub << PATH_SEP << m_partName << "." << m_extName;
368#endif
369 return true;

Callers

nothing calls this directly

Calls 9

closeMethod · 0.95
renameFunction · 0.85
acl_last_errorFunction · 0.85
last_errorFunction · 0.85
acl_make_dirsFunction · 0.85
openFunction · 0.85
last_serrorFunction · 0.50
clearMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected