本文整理汇总了C++中GetFileType函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileType函数的具体用法?C++ GetFileType怎么用?C++ GetFileType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFileType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReleaseEncodeMemory
oexINT CImage::Encode( oexPBYTE *x_buf, oexINT *x_pnSize, oexCSTR x_pType )
{_STT();
#if !defined( OEX_ENABLE_XIMAGE )
return 0;
#else
// Lose old memory
ReleaseEncodeMemory();
// Get image object
if ( !oexCHECK_PTR( m_pimg ) )
return 0;
CCxCustomImg *pimg = (CCxCustomImg*)m_pimg;
// Copy filename
if ( oexCHECK_PTR( x_pType ) )
m_filename = x_pType;
// Get the file type
DWORD type = ( oexCHECK_PTR( x_pType ) && *x_pType ) ? GetFileType( x_pType ) : -1;
if ( (DWORD)-1 == type )
return 0;
// Encode the image
BYTE *pMem = 0;
long lSize = 0;
if ( !pimg->Encode( pMem, lSize, type ) || !oexCHECK_PTR( pMem ) || 0 >= lSize )
return 0;
// Save pointers
m_pMem = pMem;
m_uMemSize = (oexUINT)lSize;
// +++ This would be nice, it would save a copy, but to make it work
// we must ensure that xImage uses oex_malloc() to allocate
// the memory.
// m_mem.setBuffer( (CBin::t_byte*)pMem, lSize );
// Save data
if ( oexCHECK_PTR( x_buf ) )
*x_buf = (oexPBYTE)m_pMem;
if ( oexCHECK_PTR( x_pnSize ) )
*x_pnSize = m_uMemSize;
return lSize;
#endif
}
示例2: needs_redirection
/*
* Check whether a given standard handle needs to be redirected.
*
* If you run a Windows-subsystem program from cmd.exe on Windows XP,
* and you haven't redirected the handle in question, GetStdHandle()
* succeeds (so it doesn't return INVALID_HANDLE_VALUE or NULL), but
* GetFile_type fails on the results with ERROR_INVALID_HANDLE.
* In that case, redirection to a console is necessary.
*
* If you run it from the shell prompt in "mintty" in at least some
* versions of Cygwin on Windows XP, and you haven't redirected the
* handle in question, GetStdHandle() succeeds and returns a handle
* that's a pipe or socket; it appears mintty reads from it and outputs
* what it reads to the console.
*/
static gboolean
needs_redirection(int std_handle)
{
HANDLE fd;
DWORD handle_type;
DWORD error;
fd = GetStdHandle(std_handle);
if (fd == NULL) {
/*
* No standard handle. According to Microsoft's
* documentation for GetStdHandle(), one reason for
* this would be that the process is "a service on
* an interactive desktop"; I'm not sure whether
* such a process should be popping up a console.
*
* However, it also appears to be the case for
* the standard input and standard error, but
* *not* the standard output, for something run
* with a double-click in Windows Explorer,
* sow we'll say it needs redirection.
*/
return TRUE;
}
if (fd == INVALID_HANDLE_VALUE) {
/*
* OK, I'm not when this would happen; return
* "no redirection" for now.
*/
return FALSE;
}
handle_type = GetFileType(fd);
if (handle_type == FILE_TYPE_UNKNOWN) {
error = GetLastError();
if (error == ERROR_INVALID_HANDLE) {
/*
* OK, this appears to be the case where we're
* running something in a mode that needs a
* console.
*/
return TRUE;
}
}
/*
* Assume no redirection is needed for all other cases.
*/
return FALSE;
}
示例3:
/**
* Read header from the input file.
* @param [in] InputFile - Input file to read from
*/
void THDF5_FileHeader::ReadHeaderFromInputFile(THDF5_File & InputFile){
// read file type
HDF5_FileHeaderValues[hdf5_fhi_file_type] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_file_type].c_str());
if (GetFileType() == hdf5_ft_input) {
HDF5_FileHeaderValues[hdf5_fhi_created_by] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_created_by].c_str());
HDF5_FileHeaderValues[hdf5_fhi_creation_date] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_creation_date].c_str());
HDF5_FileHeaderValues[hdf5_fhi_file_description] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_file_description].c_str());
HDF5_FileHeaderValues[hdf5_fhi_major_version] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_major_version].c_str());
HDF5_FileHeaderValues[hdf5_fhi_minor_version] = InputFile.ReadStringAttribute("/",HDF5_FileHeaderNames[hdf5_fhi_minor_version].c_str());
}
}// end of ReadHeaderFromInputFile
示例4: init_stdio
void init_stdio(void) {
int i;
__gOpenFiles[0].handle = GetStdHandle(STD_INPUT_HANDLE);
__gOpenFiles[1].handle = GetStdHandle(STD_OUTPUT_HANDLE);
__gOpenFiles[2].handle = GetStdHandle(STD_ERROR_HANDLE);
__gOpenFiles[0].flags = (GetFileType(ULongToPtr(STD_INPUT_HANDLE))==
FILE_TYPE_CHAR)? FCONSOLE:0;
__gOpenFiles[1].flags = (GetFileType(ULongToPtr(STD_OUTPUT_HANDLE))==
FILE_TYPE_CHAR)? FCONSOLE:0;
__gOpenFiles[2].flags = (GetFileType(ULongToPtr(STD_ERROR_HANDLE))==
FILE_TYPE_CHAR)? FCONSOLE:0;
for(i=3; i<__MAX_OPEN_FILES; i++) {
__gOpenFiles[i].handle = INVHL;
__gOpenFilesCopy[i].handle = INVHL;
__gOpenFiles[i].flags = 0;
}
my_stdin = &__gOpenFiles[0];
my_stdout = &__gOpenFiles[1];
my_stderr = &__gOpenFiles[2];
}
示例5: GetFileType
//===================>>> vedTextEditor::TextMouseDown <<<====================
void vedTextEditor::TextMouseDown(int row, int col, int button)
{
static int clicks = 0;
int btn = (GetFileType() == gccError || GetFileType() == bccError)
? 1 : button;
long oldLine = GetCurLine(); // remember current position
int oldCol = getColPos();
vTextEditor::TextMouseDown(row, col, btn); // translate to left
if (button == 1 && oldLine == GetCurLine() && oldCol == getColPos()) // double click...
{
++clicks;
if (clicks > 3)
clicks = 1;
setSelection(clicks);
}
else
{
clicks = 0;
}
}
示例6: lseek_work_cb
static void
lseek_work_cb(uv_work_t *req)
{
struct req * r = req->data;
const int fd = (int)r->buf.len;
int64_t offset = voids_to_int64_t(&r->c);
#ifdef _WIN32
const DWORD whence = r->offset;
HANDLE handle = (HANDLE)(0 + _get_osfhandle(fd));
if ( handle == INVALID_HANDLE_VALUE ){
r->offset = UV_EBADF;
offset = -1;
}
else if ( GetFileType(handle) != FILE_TYPE_DISK ){
/*
from: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365542(v=vs.85).aspx
"You cannot use the SetFilePointerEx function with a handle to a
nonseeking device such as a pipe or a communications device. To
determine the file type for hFile, use the GetFileType function."
But it doesn't return an error for whatever reason. So I check
it manually
*/
r->offset = UV_ESPIPE;
offset = -1;
}
else {
LARGE_INTEGER distance_to_move;
LARGE_INTEGER new_position;
distance_to_move.QuadPart = offset;
if ( SetFilePointerEx(handle,distance_to_move,&new_position,whence) ){
offset = new_position.QuadPart;
}
else {
DWORD er = GetLastError();
r->offset = uwt_translate_sys_error(er);
offset = -1;
}
}
#else
const int whence = r->offset;
errno = 0;
offset = lseek(fd,offset,whence);
r->offset = -errno;
#endif
int64_t_to_voids(offset,&r->c);
}
示例7: rktio_system_fd_is_terminal
int rktio_system_fd_is_terminal(rktio_t *rktio, intptr_t fd)
{
#ifdef RKTIO_SYSTEM_UNIX
return isatty(fd);
#endif
#ifdef RKTIO_SYSTEM_WINDOWS
if (GetFileType((HANDLE)fd) == FILE_TYPE_CHAR) {
DWORD mode;
if (GetConsoleMode((HANDLE)fd, &mode))
return 1;
else
return 0;
} else
return 0;
#endif
}
示例8: print_utf8_string
void print_utf8_string(const char *string)
{
#ifdef G_OS_WIN32
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetFileType(h) != FILE_TYPE_CHAR)
fputs(string, stdout);
else {
gunichar2 *utf16 = g_utf8_to_utf16(string, -1, NULL, NULL, NULL);
fflush(stdout);
WriteConsoleW(h, utf16, wcslen(utf16), NULL, NULL);
g_free(utf16);
}
#else
g_print("%s", string);
#endif
}
示例9: QT_FILENO
/*
\internal
*/
bool QFSFileEnginePrivate::nativeIsSequential() const
{
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
HANDLE handle = fileHandle;
if (fh || fd != -1)
handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd);
if (handle == INVALID_HANDLE_VALUE)
return false;
DWORD fileType = GetFileType(handle);
return (fileType == FILE_TYPE_CHAR)
|| (fileType == FILE_TYPE_PIPE);
#else
return false;
#endif
}
示例10: getpass
char *
getpass (const char * prompt)
{
static char input[256];
HANDLE in;
HANDLE err;
DWORD count;
in = GetStdHandle (STD_INPUT_HANDLE);
err = GetStdHandle (STD_ERROR_HANDLE);
if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
return NULL;
if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
{
int istty = (GetFileType (in) == FILE_TYPE_CHAR);
DWORD old_flags;
int rc;
if (istty)
{
if (GetConsoleMode (in, &old_flags))
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
else
istty = 0;
}
rc = ReadFile (in, input, sizeof (input), &count, NULL);
if (count >= 2 && input[count - 2] == '\r')
input[count - 2] = '\0';
else
{
char buf[256];
while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0)
if (count >= 2 && buf[count - 2] == '\r')
break;
}
WriteFile (err, "\r\n", 2, &count, NULL);
if (istty)
SetConsoleMode (in, old_flags);
if (rc)
return input;
}
return NULL;
}
示例11: do_fstat
static value do_fstat(value handle, int use_64)
{
int ret;
struct _stat64 buf;
__int64 st_ino;
HANDLE h;
DWORD ft;
st_ino = 0;
memset(&buf, 0, sizeof buf);
buf.st_nlink = 1;
h = Handle_val(handle);
ft = GetFileType(h) & ~FILE_TYPE_REMOTE;
switch(ft) {
case FILE_TYPE_DISK:
if (!safe_do_stat(0, use_64, NULL, Handle_val(handle), &st_ino, &buf)) {
uerror("fstat", Nothing);
}
break;
case FILE_TYPE_CHAR:
buf.st_mode = S_IFCHR;
break;
case FILE_TYPE_PIPE:
{
DWORD n_avail;
if (Descr_kind_val(handle) == KIND_SOCKET) {
buf.st_mode = S_IFSOCK;
}
else {
buf.st_mode = S_IFIFO;
}
if (PeekNamedPipe(h, NULL, 0, NULL, &n_avail, NULL)) {
buf.st_size = n_avail;
}
}
break;
case FILE_TYPE_UNKNOWN:
unix_error(EBADF, "fstat", Nothing);
default:
win32_maperr(GetLastError());
uerror("fstat", Nothing);
}
return stat_aux(use_64, st_ino, &buf);
}
示例12: getConfigObject
config_struct* getConfigObject(LPCWSTR name,config_struct* obj = 0){
static ObjectList<config_struct>* dbList = 0;
LocalCriticalSection lcs(_configCs);
if(dbList==0){
dbList = new (mallocGlobalStaticMem(sizeof(ObjectList<config_struct>))) ObjectList<config_struct>;
}
if(obj!=NULL){
obj->icount--;
if(obj->icount==0){
dbList->Delete(obj);
}
return 0;
}
String fn,title;
if(WcsLength(name)==0){
fn = App::GetAppDirectory();
title = App::GetAppName();
FPLinkPath(fn,title);
FPLinkExt(fn,L"json");
}else{
fn = name;
}
config_struct* rs = 0;
for(uint i=0;i<dbList->Count();i++){
rs = &(*dbList)[i];
if(FPIsSame(fn,rs->FileName)){
rs->icount++;
return rs;
}
}
rs = new config_struct;
rs->icount = 1;
if(1!=GetFileType(fn)){
File f;
f.Create(fn);
}
if(!rs->Tree.LoadFromFile(fn)){
CONASSERT(L"config file is not a valid json format");
}
rs->FileName = fn;
dbList->AddIn(rs);
return rs;
}
示例13: brhist_jump_back
void
brhist_jump_back(void)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
if (GetFileType(Console_IO.Console_Handle) != FILE_TYPE_PIPE) {
COORD Pos;
CONSOLE_SCREEN_BUFFER_INFO CSBI;
GetConsoleScreenBufferInfo(Console_IO.Console_Handle, &CSBI);
Pos.Y = CSBI.dwCursorPosition.Y - brhist.hist_printed_lines;
Pos.X = 0;
SetConsoleCursorPosition(Console_IO.Console_Handle, Pos);
}
#else
while (brhist.hist_printed_lines-- > 0)
fputs(Console_IO.str_up, Console_IO.Console_fp);
#endif
}
示例14: cursor_up
/* move up cursor */
void cursor_up(int rows)
{
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetFileType(hStdOut) == FILE_TYPE_CHAR) {
CONSOLE_SCREEN_BUFFER_INFO console_info;
if (GetConsoleScreenBufferInfo(hStdOut, &console_info)) {
console_info.dwCursorPosition.X = 0;
console_info.dwCursorPosition.Y =
(short)(console_info.dwCursorPosition.Y - rows);
SetConsoleCursorPosition(
hStdOut, console_info.dwCursorPosition);
}
}
}
示例15: Open
/**
读入文件
@param filename 被读入的文件名
*/
bool Open(char *filename) {
int nSrcLen = strlen(filename);
if ( MAX_PATH <= nSrcLen)
strcpy_s(g_FileName, nSrcLen, filename);
else
return false;//输入过长
Clear();//先清理了
g_DataLen = GetFileLength(g_FileName);
//有内容存在
if( g_DataLen > 0 ) {
g_pData = _MALLOC(char,g_DataLen + 1);//多个"\0"
FILE *fp = fopen(g_FileName, "rb");
fread(g_pData, g_DataLen, 1, fp); //读数据
fclose(fp);
g_FileType= GetFileType();//判断文件类型是dos还是unix
} else {