⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.h

📁 当前支持 16-bit, 32-bit and 64-bit 的二进制文件
💻 H
字号:
// util.h
// Copyright (C) 2009 Willow Schlanger

#ifndef l_util_h__included
#define l_util_h__included

#include "x86s.h"

#include <set>
#include <map>
#include <string>

namespace ceres
{

std::string fixslash(std::string s);
int string_to_unsigned(std::string s);
std::string int_to_string(int num);
std::string make_uppercase(const std::string s);
std::string make_lowercase(const std::string s);
std::string remove_extension(const std::string s);
U1 *load_file(const char *filename, U8 &size, int &status);
void split_filename(std::string filename, std::string &directory, std::string &s);

struct case_insensitive_compare_t
{
	bool operator()(const std::string &s1, const std::string &s2)
	{
		return cmp(s1, s2) < 0;
	}

	private:
	static int cmp(const std::string &s1, const std::string &s2)
	{
		std::string::const_iterator i1 = s1.begin();
		std::string::const_iterator i2 = s2.begin();
		for(;;)
		{
			if(i1 == s1.end() && i2 == s2.end())
				break;	// equal
			if(i1 == s1.end())
				return 0 - *i2;
			if(i2 == s2.end())
				return *i1 - 0;
			if(std::toupper(*i1) == std::toupper(*i2))
			{
				++i1;
				++i2;
				continue;
			}
			return (int)(unsigned)(unsigned char)(std::toupper(*i1)) - (int)(unsigned)(unsigned char)(std::toupper(*i2));
		}
		return 0;	// equal
	}
};

typedef std::set<std::string, case_insensitive_compare_t> case_insensitive_set_t;

// dll_finder_t::find() checks the current directory for the given
// file, first. if the file is not found, it checks the path list.
// it returns a path for accessing the file, or "" if not found.
// note: if a path is specified, e.g. "./x.exe", we will ONLY search
// the given path. however, we will still do a case insensitive search
// for the file. all paths are case sensitive.
class dll_finder_t
{
	std::map<std::string, case_insensitive_set_t > files;

	public:
	dll_finder_t(std::string pathlist);
	std::string find(std::string filename);

	private:
	void take_directory(std::string dir, case_insensitive_set_t &dest);
};

}	// namespace ceres

#endif	// l_util_h__included

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -