• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium OS 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 "puffin/src/unittest_common.h"
6 
7 namespace puffin {
8 
9 using std::string;
10 
MakeTempFile(string * filename,int * fd)11 bool MakeTempFile(string* filename, int* fd) {
12   char tmp_template[] = "/tmp/puffin-XXXXXX";
13   int mkstemp_fd = mkstemp(tmp_template);
14   TEST_AND_RETURN_FALSE(mkstemp_fd >= 0);
15   if (filename) {
16     *filename = tmp_template;
17   }
18   if (fd) {
19     *fd = mkstemp_fd;
20   } else {
21     close(mkstemp_fd);
22   }
23   return true;
24 }
25 
26 }  // namespace puffin
27