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

Method remove

lib_acl_cpp/src/queue/queue_file.cpp:297–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297bool queue_file::remove(void)
298{
299 this->close();
300#ifdef ACL_WINDOWS
301 if (_unlink(m_filePath.c_str()) != 0) {
302#else
303 if (unlink(m_filePath.c_str()) != 0) {
304#endif
305 logger_error("unlink %s error(%s)",
306 m_filePath.c_str(), last_serror());
307 return false;
308 }
309 return true;
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

Callers

nothing calls this directly

Calls 4

closeMethod · 0.95
unlinkFunction · 0.85
last_serrorFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected