summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorghazan <ghazan@miranda.im>2022-03-15 14:42:24 +0300
committerghazan <ghazan@miranda.im>2022-03-15 14:42:24 +0300
commit25e7342fbc71b4cd2f31432cac614150d2ceb076 (patch)
tree7cfd975a5e266c7510697d95e89b88e640d7d4ed /include
parent152bd3a7503805978ba7c9fd4f62caf74547c20b (diff)
file iterators, first version
Diffstat (limited to 'include')
-rw-r--r--include/m_core.h1
-rw-r--r--include/m_types.h25
-rw-r--r--include/m_utils.h64
3 files changed, 85 insertions, 5 deletions
diff --git a/include/m_core.h b/include/m_core.h
index 9707efab16..e1f1efdb13 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -633,6 +633,7 @@ inline int mir_vsnwprintf(_Pre_notnull_ _Always_(_Post_z_) wchar_t(&buffer)[_Siz
#endif
#else
MIR_CORE_DLL(FILE*) _wfopen(const wchar_t *pwszFileName, const wchar_t *pwszMode);
+ MIR_CORE_DLL(int) _wchdir(const wchar_t *pwszPath);
template <size_t _Size>
inline wchar_t* wcsncpy_s(wchar_t(&buffer)[_Size], const wchar_t *src, size_t len)
diff --git a/include/m_types.h b/include/m_types.h
index 1aa311feb2..f07427c1b3 100644
--- a/include/m_types.h
+++ b/include/m_types.h
@@ -53,6 +53,29 @@ using namespace std;
#define _TRUNCATE size_t(-1)
#define INVALID_HANDLE_VALUE HANDLE(-1)
+#define MB_OK 0x00000000L
+#define MB_OKCANCEL 0x00000001L
+#define MB_YESNOCANCEL 0x00000003L
+#define MB_YESNO 0x00000004L
+#define MB_RETRYCANCEL 0x00000005L
+
+#define MB_ICONSTOP 0x00000010L
+#define MB_ICONERROR 0x00000010L
+#define MB_ICONQUESTION 0x00000020L
+#define MB_ICONEXCLAMATION 0x00000030L
+#define MB_ICONWARNING 0x00000030L
+#define MB_ICONINFORMATION 0x00000040L
+
+#define IDABORT 3
+#define IDCANCEL 2
+#define IDCONTINUE 11
+#define IDIGNORE 5
+#define IDNO 7
+#define IDOK 1
+#define IDRETRY 4
+#define IDTRYAGAIN 10
+#define IDYES 6
+
typedef void *HANDLE;
typedef int BOOL, SOCKET;
typedef uint32_t UINT, COLORREF;
@@ -70,6 +93,7 @@ struct SIZE { int width, height; };
struct MSG;
struct LOGFONTA;
struct LOGFONTW;
+struct WIN32_FIND_DATA;
#define MIR_EXPORT __attribute__((__visibility__("default")))
#define MIR_IMPORT
@@ -87,6 +111,7 @@ struct LOGFONTW;
#define _Printf_format_string_
#define _countof(array) (sizeof(array) / sizeof(array[0]))
#define __forceinline inline __attribute__ ((always_inline))
+#define __fallthrough
#define InterlockedIncrement(x) __sync_fetch_and_add(x, 1)
#define InterlockedDecrement(x) __sync_fetch_and_add(x, -1)
diff --git a/include/m_utils.h b/include/m_utils.h
index 026666bbce..f7b505815e 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -228,11 +228,12 @@ EXTERN_C MIR_CORE_DLL(int) Utils_AssertInsideScreen(RECT *rc);
#define WNDCLASS_COLOURPICKER "ColourPicker"
-#define CPM_SETCOLOUR 0x1000 //lParam = new colour
-#define CPM_GETCOLOUR 0x1001 //returns colour
-#define CPM_SETDEFAULTCOLOUR 0x1002 //lParam = default, used as first custom colour
-#define CPM_GETDEFAULTCOLOUR 0x1003 //returns colour
-#define CPN_COLOURCHANGED 1 //sent through WM_COMMAND
+#define CPM_SETCOLOUR 0x1000 //lParam = new colour
+#define CPM_GETCOLOUR 0x1001 //returns colour
+#define CPM_SETDEFAULTCOLOUR 0x1002 //lParam = default, used as first custom colour
+#define CPM_GETDEFAULTCOLOUR 0x1003 //returns colour
+
+#define CPN_COLOURCHANGED 1 //sent through WM_COMMAND
/////////////////////////////////////////////////////////////////////////////////////////
// Gets the filter strings for use in the open file dialog
@@ -244,6 +245,50 @@ EXTERN_C MIR_CORE_DLL(HBITMAP) Bitmap_Load(const wchar_t *ptszFileName);
EXTERN_C MIR_CORE_DLL(void) Bitmap_GetFilter(wchar_t *dest, size_t destLen);
/////////////////////////////////////////////////////////////////////////////////////////
+// Path class
+
+class MIR_CORE_EXPORT MFilePath : public CMStringW
+{
+ class MIR_CORE_EXPORT MFileIterator
+ {
+ class iterator
+ {
+ const MFileIterator &ptr;
+ int code = 0;
+
+ public:
+ __inline iterator(const MFileIterator &_p, int code) : ptr(_p) {}
+ iterator operator++();
+ __inline bool operator!=(const iterator &p) { return p.code == code; }
+ __inline operator const MFileIterator*() const { return &ptr; }
+ };
+
+ public:
+ MFileIterator(const wchar_t*);
+ ~MFileIterator();
+
+ wchar_t m_path[MAX_PATH];
+ bool isDir() const;
+
+ __inline iterator begin() const;
+ __inline iterator end() const { return iterator(*this, 0); }
+ };
+
+public:
+ MFilePath(): CMStringW() {}
+ MFilePath(const wchar_t *init) : CMStringW(init) {}
+ MFilePath& operator=(const wchar_t *pszSrc) {
+ *this = pszSrc;
+ return *this;
+ }
+
+ bool isExist() const;
+ bool move(const wchar_t *pwszDest);
+
+ MFileIterator search();
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Converts a path to a relative path
// Only saves as a relative path if the file is in the miranda directory (or
// sub directory)
@@ -379,6 +424,15 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Utils_ReplaceVarsW(const wchar_t *szData, MCONTAC
#endif
/////////////////////////////////////////////////////////////////////////////////////////
+// compatibility functions
+
+#ifndef _WINDOWS
+MIR_CORE_DLL(int) GetShortPathNameW(const wchar_t*, wchar_t*, int);
+MIR_CORE_DLL(int) MessageBoxW(HWND, const wchar_t*, const wchar_t*, int);
+MIR_CORE_DLL(int) WritePrivateProfileString(const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
// enters one string
// returns TRUE on pressing OK or FALSE if Cancel was pressed