Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b5c569cd
Commit
b5c569cd
authored
Aug 20, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/FileDescriptor: add IsPipe(), IsSocket()
parent
11396d4f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
SocketDescriptor.hxx
src/net/SocketDescriptor.hxx
+1
-0
FileDescriptor.cxx
src/system/FileDescriptor.cxx
+14
-0
FileDescriptor.hxx
src/system/FileDescriptor.hxx
+12
-0
No files found.
src/net/SocketDescriptor.hxx
View file @
b5c569cd
...
...
@@ -80,6 +80,7 @@ public:
using
FileDescriptor
::
IsDefined
;
#ifndef _WIN32
using
FileDescriptor
::
IsValid
;
using
FileDescriptor
::
IsSocket
;
#endif
using
FileDescriptor
::
Get
;
using
FileDescriptor
::
Set
;
...
...
src/system/FileDescriptor.cxx
View file @
b5c569cd
...
...
@@ -65,6 +65,20 @@ FileDescriptor::IsValid() const noexcept
return
IsDefined
()
&&
fcntl
(
fd
,
F_GETFL
)
>=
0
;
}
bool
FileDescriptor
::
IsPipe
()
const
noexcept
{
struct
stat
st
;
return
IsDefined
()
&&
fstat
(
fd
,
&
st
)
==
0
&&
S_ISFIFO
(
st
.
st_mode
);
}
bool
FileDescriptor
::
IsSocket
()
const
noexcept
{
struct
stat
st
;
return
IsDefined
()
&&
fstat
(
fd
,
&
st
)
==
0
&&
S_ISSOCK
(
st
.
st_mode
);
}
#endif
bool
...
...
src/system/FileDescriptor.hxx
View file @
b5c569cd
...
...
@@ -75,6 +75,18 @@ public:
*/
gcc_pure
bool
IsValid
()
const
noexcept
;
/**
* Ask the kernel whether this is a pipe.
*/
gcc_pure
bool
IsPipe
()
const
noexcept
;
/**
* Ask the kernel whether this is a socket descriptor.
*/
gcc_pure
bool
IsSocket
()
const
noexcept
;
#endif
/**
...
...
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