foobar2000 SDK
2015-08-03
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
pfc
filehandle.cpp
Go to the documentation of this file.
1
#include "
pfc.h
"
2
3
#ifndef _WIN32
4
#include <unistd.h>
5
#endif
6
7
namespace
pfc
{
8
void
fileHandleClose
(
fileHandle_t
h ) {
9
if
(h ==
fileHandleInvalid
)
return
;
10
#ifdef _WIN32
11
CloseHandle( h );
12
#else
13
close( h );
14
#endif
15
}
16
17
fileHandle_t
fileHandleDup
(
fileHandle_t
h ) {
18
#ifdef _WIN32
19
auto
proc = GetCurrentProcess();
20
HANDLE
out;
21
if
(!DuplicateHandle ( proc, h, proc, &out, 0, FALSE, DUPLICATE_SAME_ACCESS ))
return
fileHandleInvalid
;
22
return
out;
23
#else
24
return
dup( h );
25
#endif
26
}
27
28
void
fileHandle::close
() {
29
fileHandleClose
(
h
);
30
clear
();
31
}
32
33
}
pfc::fileHandle_t
HANDLE fileHandle_t
Definition:
filehandle.h:3
pfc::fileHandle::close
void close()
Definition:
filehandle.cpp:28
pfc.h
pfc::fileHandle::h
fileHandle_t h
Definition:
filehandle.h:24
pfc
Definition:
file_info_impl.h:22
HANDLE
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
pfc::fileHandleDup
fileHandle_t fileHandleDup(fileHandle_t h)
Definition:
filehandle.cpp:17
pfc::fileHandleInvalid
const fileHandle_t fileHandleInvalid
Definition:
filehandle.h:4
pfc::fileHandle::clear
void clear()
Definition:
filehandle.h:22
pfc::fileHandleClose
void fileHandleClose(fileHandle_t h)
Definition:
filehandle.cpp:8
Generated by
1.8.11