view include/animone/util/win32.h @ 23:1cfa7d57c022

dep/animone: add experimental accessibility strategy I also moved most of the functions out of util/win32.cc, because that file is meant for things that are shared between the different functions, and currently that is only wide string conversion helpers.
author Paper <paper@paper.us.eu.org>
date Wed, 19 Jun 2024 23:13:55 -0400
parents 27b988a1048c
children 60ded877339b
line wrap: on
line source

#ifndef ANIMONE_ANIMONE_UTIL_WIN32_H_
#define ANIMONE_ANIMONE_UTIL_WIN32_H_

#include <windef.h>
#include <subauth.h>
#include <handleapi.h>

#include <memory>
#include <string>

namespace animone::internal::win32 {

struct HandleDeconstructor {
	using pointer = HANDLE;
	void operator()(pointer t) const { ::CloseHandle(t); };
};

using Handle = std::unique_ptr<HANDLE, HandleDeconstructor>;

/* ----------------------------------------------- */

std::string ToUtf8String(const std::wstring& string);
std::string ToUtf8String(const UNICODE_STRING& string);
std::wstring ToWstring(const std::string& string);

/* XXX can this stuff be moved to fd/win32.cc? */
bool IsSystemDirectory(const std::string& path);
bool IsSystemDirectory(std::wstring path);

} // namespace animone::internal::win32

#endif // ANIMONE_ANIMONE_UTIL_WIN32_H_