//
// Created by Ht on 2019/7/29.
//

#ifndef PROJECT_ESYSTEMUTIL_H
#define PROJECT_ESYSTEMUTIL_H

#include <string>
#include "sysdef.h"
#include <jebase/config.h>
#include <vector>
#include <mutex>

class JE_API SystemUtil {

public:
    static std::string system(const char *cmd, int buffSize = 256);

    static std::string getCurrentPath();

    //加载路径下的目录列表到目标变量中
    static void loadFileList(const std::string& dirName, std::vector<std::string> fileList);

    static int SysSleep(unsigned long msecs, bool inerruptable = true);

    static void tryWait(unsigned long ms);

    static void createDirs(const std::string& dir);
};

//线程互锁
#define SINGLE_LOCK(m) std::unique_lock<std::mutex>  __locker##m(m)
#define SINGLE_LOCK_A(m,a) std::unique_lock<std::mutex>  __locker##m##a(m)
#define SINGLE_LOCK_B(m,a) std::unique_lock<std::mutex>  __locker##a(m)
//线程重入
#define RECURSIVE_LOCK(m) std::unique_lock<std::recursive_mutex>  __locker##m(m)
#define RECURSIVE_LOCK_A(m,a) std::unique_lock<std::recursive_mutex>  __locker##m##a(m)
#define RECURSIVE_LOCK_B(m,b) std::unique_lock<std::recursive_mutex>  __locker##a(m)
//直接访问名字
#define LOCKER_NAME(m) __locker##m
#define LOCKER_NAME_A(m,a) __locker##m##a

#endif //PROJECT_ESYSTEMUTIL_H
