CommonUtil.h 1.2 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6 7 8
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include <string>
G
groot 已提交
9
#include <time.h>
G
groot 已提交
10 11 12 13

#include "Error.h"

namespace zilliz {
J
jinhai 已提交
14
namespace milvus {
G
groot 已提交
15 16 17 18 19 20 21 22 23 24 25
namespace server {

class CommonUtil {
 public:
    static bool GetSystemMemInfo(unsigned long &totalMem, unsigned long &freeMem);
    static bool GetSystemAvailableThreads(unsigned int &threadCnt);

    static bool IsFileExist(const std::string &path);
    static bool IsDirectoryExit(const std::string &path);
    static ServerError CreateDirectory(const std::string &path);
    static ServerError DeleteDirectory(const std::string &path);
G
groot 已提交
26 27

    static std::string GetExePath();
G
groot 已提交
28

G
groot 已提交
29 30 31 32 33 34 35
    static bool TimeStrToTime(const std::string& time_str,
            time_t &time_integer,
            tm &time_struct,
            const std::string& format = "%d-%d-%d %d:%d:%d");

    static void ConvertTime(time_t time_integer, tm &time_struct);
    static void ConvertTime(tm time_struct, time_t &time_integer);
G
groot 已提交
36 37 38 39 40 41
};

}
}
}