Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main Repositories
otb
Commits
eb690f1b
Commit
eb690f1b
authored
6 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: wrap for isatty()
parent
d47e53b8
No related branches found
No related tags found
2 merge requests
!621
Release 7.0 (master)
,
!364
No progress to file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/Core/Common/include/otbSystem.h
+3
-0
3 additions, 0 deletions
Modules/Core/Common/include/otbSystem.h
Modules/Core/Common/src/otbSystem.cxx
+35
-0
35 additions, 0 deletions
Modules/Core/Common/src/otbSystem.cxx
with
38 additions
and
0 deletions
Modules/Core/Common/include/otbSystem.h
+
3
−
0
View file @
eb690f1b
...
...
@@ -61,6 +61,9 @@ public:
/** Parse a filename with additional information */
static
bool
ParseFileNameForAdditionalInfo
(
const
std
::
string
&
id
,
std
::
string
&
file
,
unsigned
int
&
addNum
);
/** Returns true if the file descriptor fd is interactive (i.e. like isatty on unix) */
static
bool
IsInteractive
(
int
fd
);
};
}
// namespace otb
...
...
This diff is collapsed.
Click to expand it.
Modules/Core/Common/src/otbSystem.cxx
+
35
−
0
View file @
eb690f1b
...
...
@@ -28,6 +28,7 @@
/*=====================================================================
WIN32 / MSVC++ implementation
*====================================================================*/
#include
<Windows.h>
#ifndef WIN32CE
# include <io.h>
#else
...
...
@@ -37,6 +38,7 @@
/*=====================================================================
POSIX (Unix) implementation
*====================================================================*/
#include
<unistd.h>
#include
<sys/types.h>
#include
<dirent.h>
#endif
...
...
@@ -202,4 +204,37 @@ bool System::ParseFileNameForAdditionalInfo(const std::string& id, std::string&
return
true
;
}
bool
System
::
IsInteractive
(
int
fd
)
{
#if (defined(WIN32) || defined(WIN32CE)) && !defined(__CYGWIN__) && !defined(__MINGW32__)
// Windows implementation
HANDLE
hcon
;
/* get OS handle of the file descriptor */
hcon
=
(
HANDLE
)
_get_osfhandle
(
fd
);
if
(
hcon
==
INVALID_HANDLE_VALUE
)
return
false
;
/* check if its a device (i.e. console, printer, serial port) */
if
(
GetFileType
(
hcon
)
!=
FILE_TYPE_CHAR
)
return
false
;
/* check if its a handle to a console output screen buffer */
CONSOLE_SCREEN_BUFFER_INFO
screenBufferInfo
;
DWORD
mode
;
if
(
!
fd
)
{
if
(
!
GetConsoleMode
(
hcon
,
&
mode
))
return
false
;
}
else
if
(
!
GetConsoleScreenBufferInfo
(
hcon
,
&
screenBufferInfo
))
return
false
;
return
true
;
#else
// Unix implementation
return
isatty
(
fd
);
#endif
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment