1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/android/fifo_utils.h"
6
7 #include <sys/stat.h>
8
9 #include "base/files/file_path.h"
10
11 namespace base {
12 namespace android {
13
CreateFIFO(const FilePath & path,int mode)14 bool CreateFIFO(const FilePath& path, int mode) {
15 // Default permissions for mkfifo() is ignored, chmod() is required.
16 return mkfifo(path.value().c_str(), mode) == 0 &&
17 chmod(path.value().c_str(), mode) == 0;
18 }
19
RedirectStream(FILE * stream,const FilePath & path,const char * mode)20 bool RedirectStream(FILE* stream, const FilePath& path, const char* mode) {
21 return freopen(path.value().c_str(), mode, stream) != NULL;
22 }
23
24 } // namespace android
25 } // namespace base
26