summaryrefslogtreecommitdiff
path: root/core/pkg
diff options
context:
space:
mode:
authorruki <[email protected]>2015-05-04 22:05:39 +0800
committerruki <[email protected]>2015-05-04 23:42:09 +0800
commit00cd7e605400a459822294f3ceff5194cf9b56d5 (patch)
treeb600091426bc69a535338cc84e702f16d6f7b044 /core/pkg
parent781bfd2dc99c8e0ca3063b6a3d6199f2390951f4 (diff)
add some path and string interfaces
Diffstat (limited to 'core/pkg')
-rw-r--r--core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h2
-rw-r--r--core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h4
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/platform/directory.h13
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/platform/path.h45
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h1
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h73
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h4
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/prefix/trace.h24
-rw-r--r--core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdbbin290816 -> 290816 bytes
-rw-r--r--core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdbbin282624 -> 282624 bytes
10 files changed, 142 insertions, 24 deletions
diff --git a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h
index 1a64bb537..d05f235cd 100644
--- a/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h
+++ b/core/pkg/tbox.pkg/inc/mac/x64/tbox.config.h
@@ -14,7 +14,7 @@
#define TB_CONFIG_VERSION_ALTER 8
// build version
-#define TB_CONFIG_VERSION_BUILD 201504251218
+#define TB_CONFIG_VERSION_BUILD 201505041915
// small
#define TB_CONFIG_SMALL (0)
diff --git a/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h b/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h
index cf912fd77..8bfead6db 100644
--- a/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h
+++ b/core/pkg/tbox.pkg/inc/msvc/x86/tbox.config.h
@@ -15,10 +15,10 @@
#define TB_CONFIG_VERSION_ALTER 8
// build version
-#define TB_CONFIG_VERSION_BUILD 201504271443
+#define TB_CONFIG_VERSION_BUILD 201505042322
// small
-#define TB_CONFIG_SMALL (1)
+#define TB_CONFIG_SMALL (0)
// os
#define TB_CONFIG_OS_WINDOWS
diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h
index 31dded3ca..e011ad0ac 100755
--- a/core/pkg/tbox.pkg/inc/tbox/platform/directory.h
+++ b/core/pkg/tbox.pkg/inc/tbox/platform/directory.h
@@ -61,14 +61,14 @@ tb_bool_t tb_directory_create(tb_char_t const* path);
*/
tb_bool_t tb_directory_remove(tb_char_t const* path);
-/*! the temporary directory
+/*! the home directory
*
* @param path the directory path data
* @param maxn the directory path maxn
*
* @return the directory path size
*/
-tb_size_t tb_directory_temporary(tb_char_t* path, tb_size_t maxn);
+tb_size_t tb_directory_home(tb_char_t* path, tb_size_t maxn);
/*! the current directory
*
@@ -79,6 +79,15 @@ tb_size_t tb_directory_temporary(tb_char_t* path, tb_size_t maxn);
*/
tb_size_t tb_directory_current(tb_char_t* path, tb_size_t maxn);
+/*! the temporary directory
+ *
+ * @param path the directory path data
+ * @param maxn the directory path maxn
+ *
+ * @return the directory path size
+ */
+tb_size_t tb_directory_temporary(tb_char_t* path, tb_size_t maxn);
+
/*! the directory walk
*
* @param path the directory path
diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/path.h b/core/pkg/tbox.pkg/inc/tbox/platform/path.h
index 0335f5807..878c34e84 100755
--- a/core/pkg/tbox.pkg/inc/tbox/platform/path.h
+++ b/core/pkg/tbox.pkg/inc/tbox/platform/path.h
@@ -37,21 +37,56 @@ __tb_extern_c_enter__
/* //////////////////////////////////////////////////////////////////////////////////////
* macros
*/
+
+// the path maximum
#define TB_PATH_MAXN (4096)
/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
*/
-/*! the full path
+/*! translate the path to the native path
+ *
+ * - transform the path separator
+ * - remove the repeat path separator
+ * - expand the user directory with the prefix: ~
+ *
+ * @param path the path
+ * @param size the path size, optional
+ * @param maxn the path maxn
+ *
+ * @return tb_true or tb_false
+ */
+tb_size_t tb_path_translate(tb_char_t* path, tb_size_t size, tb_size_t maxn);
+
+/*! the path is absolute?
+ *
+ * @param path the path
+ *
+ * @return tb_true or tb_false
+ */
+tb_bool_t tb_path_is_absolute(tb_char_t const* path);
+
+/*! get the absolute path which relative to the current directory
+ *
+ * @param path the path
+ * @param data the path data
+ * @param maxn the path maxn
+ *
+ * @return the absolute path
+ */
+tb_char_t const* tb_path_absolute(tb_char_t const* path, tb_char_t* data, tb_size_t maxn);
+
+/*! get the absolute path which relative to the given root directory
*
- * @param path the path path
- * @param full the full path
+ * @param root the root path
+ * @param path the path
+ * @param data the path data
* @param maxn the path maxn
*
- * @return the full path
+ * @return the absolute path
*/
-tb_char_t const* tb_path_full(tb_char_t const* path, tb_char_t* full, tb_size_t maxn);
+tb_char_t const* tb_path_absolute_to(tb_char_t const* root, tb_char_t const* path, tb_char_t* data, tb_size_t maxn);
/* //////////////////////////////////////////////////////////////////////////////////////
* extern
diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h
index 55b54498d..24e843258 100755
--- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h
+++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/interface.h
@@ -30,6 +30,7 @@
#include "user32.h"
#include "ws2_32.h"
#include "mswsock.h"
+#include "shell32.h"
#include "dbghelp.h"
#include "kernel32.h"
#include "iphlpapi.h"
diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h
new file mode 100755
index 000000000..54f3d38ca
--- /dev/null
+++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/interface/shell32.h
@@ -0,0 +1,73 @@
+/*!The Treasure Box Library
+ *
+ * TBox is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * TBox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with TBox;
+ * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+ *
+ * Copyright (C) 2009 - 2015, ruki All rights reserved.
+ *
+ * @author ruki
+ * @file shell32.h
+ *
+ */
+#ifndef TB_PLATFORM_WINDOWS_INTERFACE_SHELL32_H
+#define TB_PLATFORM_WINDOWS_INTERFACE_SHELL32_H
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * extern
+ */
+__tb_extern_c_enter__
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * types
+ */
+
+// the SHGetSpecialFolderLocation func type
+typedef HRESULT (WINAPI* tb_shell32_SHGetSpecialFolderLocation_t)(HWND hwndOwner, tb_int_t nFolder, tb_handle_t *ppidl);
+
+// the SHGetPathFromIDListW func type
+typedef BOOL (WINAPI* tb_shell32_SHGetPathFromIDListW_t)(tb_handle_t pidl, LPWSTR pszPath);
+
+// the shell32 interfaces type
+typedef struct __tb_shell32_t
+{
+ // SHGetSpecialFolderLocation
+ tb_shell32_SHGetSpecialFolderLocation_t SHGetSpecialFolderLocation;
+
+ // SHGetPathFromIDListW
+ tb_shell32_SHGetPathFromIDListW_t SHGetPathFromIDListW;
+
+}tb_shell32_t, *tb_shell32_ref_t;
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * interfaces
+ */
+
+/* the shell32 interfaces
+ *
+ * @return the shell32 interfaces pointer
+ */
+tb_shell32_ref_t tb_shell32(tb_noarg_t);
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * extern
+ */
+__tb_extern_c_leave__
+
+
+#endif
diff --git a/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h b/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h
index 5fd75e83a..d14a6fea8 100755
--- a/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h
+++ b/core/pkg/tbox.pkg/inc/tbox/platform/windows/prefix.h
@@ -50,11 +50,11 @@ static __tb_inline__ tb_time_t tb_filetime_to_time(FILETIME ft)
}
// the path full for wchar
-static __tb_inline__ tb_wchar_t const* tb_path_full_w(tb_char_t const* path, tb_wchar_t* full, tb_size_t maxn)
+static __tb_inline__ tb_wchar_t const* tb_path_absolute_w(tb_char_t const* path, tb_wchar_t* full, tb_size_t maxn)
{
// the path full
tb_char_t full_a[TB_PATH_MAXN] = {0};
- if (!tb_path_full(path, full_a, TB_PATH_MAXN)) return tb_null;
+ if (!tb_path_absolute(path, full_a, TB_PATH_MAXN)) return tb_null;
// atow
tb_size_t size = tb_atow(full, full_a, maxn);
diff --git a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h
index 2804577dd..15fcbf4a4 100755
--- a/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h
+++ b/core/pkg/tbox.pkg/inc/tbox/prefix/trace.h
@@ -66,12 +66,12 @@ __tb_extern_c_enter__
# define tb_tracef_assert_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: " fmt " at %s(): %d, %s", ##arg, __tb_func__, __tb_line__, __tb_file__); tb_trace_sync(); } while (0)
# define tb_tracef_warning_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: " fmt " at %s(): %d, %s", ##arg, __tb_func__, __tb_line__, __tb_file__); tb_trace_sync(); } while (0)
# else
-# define tb_trace_error_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[error]: " fmt __tb_newline__, ##arg); tb_trace_sync(); } while (0)
-# define tb_trace_assert_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: " fmt __tb_newline__, ##arg); tb_trace_sync(); } while (0)
-# define tb_trace_warning_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: " fmt __tb_newline__, ##arg); tb_trace_sync(); } while (0)
-# define tb_tracef_error_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[error]: " fmt, ##arg); tb_trace_sync(); } while (0)
-# define tb_tracef_assert_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: " fmt, ##arg); tb_trace_sync(); } while (0)
-# define tb_tracef_warning_p(prefix, fmt, arg ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: " fmt, ##arg); tb_trace_sync(); } while (0)
+# define tb_trace_error_p(prefix, fmt, arg ...)
+# define tb_trace_assert_p(prefix, fmt, arg ...)
+# define tb_trace_warning_p(prefix, fmt, arg ...)
+# define tb_tracef_error_p(prefix, fmt, arg ...)
+# define tb_tracef_assert_p(prefix, fmt, arg ...)
+# define tb_tracef_warning_p(prefix, fmt, arg ...)
# endif
#elif defined(TB_COMPILER_IS_MSVC) && TB_COMPILER_VERSION_BE(13, 0)
# define tb_trace_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, fmt __tb_newline__, __VA_ARGS__); } while (0)
@@ -84,12 +84,12 @@ __tb_extern_c_enter__
# define tb_tracef_assert_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: at %s(): %d, %s: " fmt, __tb_func__, __tb_line__, __tb_file__, __VA_ARGS__); tb_trace_sync(); } while (0)
# define tb_tracef_warning_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: at %s(): %d, %s: " fmt, __tb_func__, __tb_line__, __tb_file__, __VA_ARGS__); tb_trace_sync(); } while (0)
# else
-# define tb_trace_error_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[error]: " fmt __tb_newline__, __VA_ARGS__); tb_trace_sync(); } while (0)
-# define tb_trace_assert_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: " fmt __tb_newline__, __VA_ARGS__); tb_trace_sync(); } while (0)
-# define tb_trace_warning_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: " fmt __tb_newline__, __VA_ARGS__); tb_trace_sync(); } while (0)
-# define tb_tracef_error_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[error]: " fmt, __VA_ARGS__); tb_trace_sync(); } while (0)
-# define tb_tracef_assert_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[assert]: " fmt, __VA_ARGS__); tb_trace_sync(); } while (0)
-# define tb_tracef_warning_p(prefix, fmt, ...) do { tb_trace_done(prefix, TB_TRACE_MODULE_NAME, "[warning]: " fmt, __VA_ARGS__); tb_trace_sync(); } while (0)
+# define tb_trace_error_p(prefix, fmt, ...)
+# define tb_trace_assert_p(prefix, fmt, ...)
+# define tb_trace_warning_p(prefix, fmt, ...)
+# define tb_tracef_error_p(prefix, fmt, ...)
+# define tb_tracef_assert_p(prefix, fmt, ...)
+# define tb_tracef_warning_p(prefix, fmt, ...)
# endif
#else
# define tb_trace_p
diff --git a/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb b/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb
index 522dedf4d..33b90d45d 100644
--- a/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb
+++ b/core/pkg/tbox.pkg/lib/msvc/x86/tboxd.pdb
Binary files differ
diff --git a/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb b/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb
index 895a17b7e..136751985 100644
--- a/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb
+++ b/core/pkg/tbox.pkg/lib/msvc/x86/tboxr.pdb
Binary files differ