Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
56bec381
Commit
56bec381
authored
Sep 12, 2017
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
d8c34b99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
15 deletions
+38
-15
log2.h
log2.h
+19
-11
file_op.h
win32/file_op.h
+19
-4
No files found.
log2.h
View file @
56bec381
...
@@ -101,7 +101,7 @@ inline void dump_hex(const void* buff, size_t buff_len)
...
@@ -101,7 +101,7 @@ inline void dump_hex(const void* buff, size_t buff_len)
return
;
return
;
}
}
char
output
[
4096
]
=
{
0
};
char
output
[
MAX_OUT_BUFF_LEN
]
=
{
0
};
char
c
[
128
]
=
{
0
};
char
c
[
128
]
=
{
0
};
std
::
sprintf
(
c
,
"dump_hex: buff 0x%p, buff_len %zu
\n
"
,
buff
,
buff_len
);
std
::
sprintf
(
c
,
"dump_hex: buff 0x%p, buff_len %zu
\n
"
,
buff
,
buff_len
);
...
@@ -124,7 +124,7 @@ inline void dump_hex(const void* buff, size_t buff_len)
...
@@ -124,7 +124,7 @@ inline void dump_hex(const void* buff, size_t buff_len)
JLOG_WARN
(
output
);
JLOG_WARN
(
output
);
}
}
inline
void
dump_asc
(
const
void
*
buff
,
size_t
buff_len
)
inline
void
dump_asc
(
const
void
*
buff
,
size_t
buff_len
,
bool
seperate_with_space
=
true
,
bool
force_new_line
=
true
)
{
{
size_t
output_len
=
buff_len
*
6
+
64
;
size_t
output_len
=
buff_len
*
6
+
64
;
if
(
output_len
>
MAX_OUT_BUFF_LEN
)
{
if
(
output_len
>
MAX_OUT_BUFF_LEN
)
{
...
@@ -132,22 +132,30 @@ inline void dump_asc(const void* buff, size_t buff_len)
...
@@ -132,22 +132,30 @@ inline void dump_asc(const void* buff, size_t buff_len)
return
;
return
;
}
}
char
output
[
4096
]
=
{
0
};
char
output
[
MAX_OUT_BUFF_LEN
]
=
{
0
};
char
c
[
128
]
=
{
0
};
char
c
[
128
]
=
{
0
};
std
::
sprintf
(
c
,
"dump_asc: buff 0x%p, buff_len %zu
\n
"
,
buff
,
buff_len
);
std
::
sprintf
(
c
,
"dump_asc: buff 0x%p, buff_len %zu
\n
"
,
buff
,
buff_len
);
std
::
strcat
(
output
,
c
);
std
::
strcat
(
output
,
"
\n
"
);
for
(
size_t
i
=
0
;
i
<
16
;
i
++
)
{
if
(
force_new_line
)
{
char
tmp
[
4
];
for
(
size_t
i
=
0
;
i
<
16
;
i
++
)
{
std
::
sprintf
(
tmp
,
"%02zX "
,
i
);
char
tmp
[
4
];
std
::
strcat
(
c
,
tmp
);
std
::
sprintf
(
tmp
,
"%02zX"
,
i
);
std
::
strcat
(
c
,
tmp
);
if
(
seperate_with_space
)
{
std
::
strcat
(
c
,
" "
);
}
}
std
::
strcat
(
output
,
c
);
std
::
strcat
(
output
,
"
\n
"
);
}
}
std
::
strcat
(
output
,
c
);
std
::
strcat
(
output
,
"
\n
"
);
for
(
size_t
i
=
0
;
i
<
buff_len
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
buff_len
;
i
++
)
{
std
::
sprintf
(
c
,
"%c "
,
reinterpret_cast
<
const
char
*>
(
buff
)[
i
]);
std
::
sprintf
(
c
,
"%c"
,
reinterpret_cast
<
const
char
*>
(
buff
)[
i
]);
if
(
seperate_with_space
)
{
std
::
strcat
(
c
,
" "
);
}
std
::
strcat
(
output
,
c
);
std
::
strcat
(
output
,
c
);
if
(
i
>
0
&&
(
i
+
1
)
%
16
==
0
)
{
if
(
force_new_line
&&
i
>
0
&&
(
i
+
1
)
%
16
==
0
)
{
std
::
strcat
(
output
,
"
\n
"
);
std
::
strcat
(
output
,
"
\n
"
);
}
}
}
}
...
...
win32/file_op.h
View file @
56bec381
#pragma once
#pragma once
namespace
jlib
{
namespace
jlib
{
inline
bool
get_file_open_dialog_result
(
std
::
wstring
&
path
,
HWND
hWnd
=
nullptr
)
{
inline
bool
get_file_open_dialog_result
(
std
::
wstring
&
path
,
HWND
hWnd
=
nullptr
,
const
std
::
wstring
&
ext
=
L""
,
UINT
cFileTypes
=
0
,
const
COMDLG_FILTERSPEC
*
rgFilterSpec
=
nullptr
)
{
bool
ok
=
false
;
bool
ok
=
false
;
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
|
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
|
...
@@ -16,6 +20,18 @@ inline bool get_file_open_dialog_result(std::wstring& path, HWND hWnd = nullptr)
...
@@ -16,6 +20,18 @@ inline bool get_file_open_dialog_result(std::wstring& path, HWND hWnd = nullptr)
IID_IFileOpenDialog
,
reinterpret_cast
<
void
**>
(
&
pFileOpen
));
IID_IFileOpenDialog
,
reinterpret_cast
<
void
**>
(
&
pFileOpen
));
if
(
SUCCEEDED
(
hr
))
{
if
(
SUCCEEDED
(
hr
))
{
if
(
!
ext
.
empty
())
{
pFileOpen
->
SetDefaultExtension
(
ext
.
c_str
());
}
if
(
cFileTypes
!=
0
&&
rgFilterSpec
)
{
pFileOpen
->
SetFileTypes
(
cFileTypes
,
rgFilterSpec
);
}
if
(
!
hWnd
)
{
hWnd
=
::
GetDesktopWindow
();
}
// Show the Open dialog box.
// Show the Open dialog box.
hr
=
pFileOpen
->
Show
(
hWnd
);
hr
=
pFileOpen
->
Show
(
hWnd
);
...
@@ -45,12 +61,11 @@ inline bool get_file_open_dialog_result(std::wstring& path, HWND hWnd = nullptr)
...
@@ -45,12 +61,11 @@ inline bool get_file_open_dialog_result(std::wstring& path, HWND hWnd = nullptr)
return
ok
;
return
ok
;
}
}
inline
bool
get_save_as_dialog_path
(
std
::
wstring
&
path
,
inline
bool
get_save_as_dialog_path
(
std
::
wstring
&
path
,
HWND
hWnd
=
nullptr
,
const
std
::
wstring
&
ext
=
L""
,
const
std
::
wstring
&
ext
=
L""
,
UINT
cFileTypes
=
0
,
UINT
cFileTypes
=
0
,
const
COMDLG_FILTERSPEC
*
rgFilterSpec
=
nullptr
,
const
COMDLG_FILTERSPEC
*
rgFilterSpec
=
nullptr
)
{
HWND
hWnd
=
nullptr
)
{
bool
ok
=
false
;
bool
ok
=
false
;
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
|
HRESULT
hr
=
CoInitializeEx
(
NULL
,
COINIT_APARTMENTTHREADED
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment