1fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle/* 2fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * Copyright (C) 2014 The Android Open Source Project 3fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * 4fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * Licensed under the Apache License, Version 2.0 (the "License"); 5fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * you may not use this file except in compliance with the License. 6fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * You may obtain a copy of the License at 7fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * 8fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * http://www.apache.org/licenses/LICENSE-2.0 9fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * 10fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * Unless required by applicable law or agreed to in writing, software 11fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * distributed under the License is distributed on an "AS IS" BASIS, 12fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * See the License for the specific language governing permissions and 14fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle * limitations under the License. 15fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle */ 16fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle 17d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle#include <ftw.h> 18fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle#include <stdlib.h> 19fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle 2031165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes// Delegation will work in these cases because all the transitive dependencies 2131165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes// are already 64-bit ready. In particular, we don't have non-O_LARGEFILE 2231165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes// open (our open is actually open64) and stat and stat64 are the same. 2331165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesint mkstemp64(char* path) { 2431165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes return mkstemp(path); 2531165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes} 2631165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesint mkostemp64(char* path, int flags) { 2731165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes return mkostemp(path, flags); 2831165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes} 2931165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesint mkstemps64(char* path, int suffix_length) { 3031165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes return mkstemps(path, suffix_length); 3131165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes} 3231165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesint mkostemps64(char* path, int suffix_length, int flags) { 3331165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes return mkostemps(path, suffix_length, flags); 34fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravle} 35d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle 36d4934a70e69365c97b1378820152e134a0089b5eCalin Juravletypedef int (*ftw_fn)(const char*, const struct stat*, int); 37d4934a70e69365c97b1378820152e134a0089b5eCalin Juravletypedef int (*nftw_fn)(const char*, const struct stat*, int, struct FTW*); 38d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle 39d4934a70e69365c97b1378820152e134a0089b5eCalin Juravleint ftw64(const char *dirpath, 40d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle int (*fn)(const char*, const struct stat64*, int), int nopenfd) { 41d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle return ftw(dirpath, reinterpret_cast<ftw_fn>(fn), nopenfd); 42d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle} 43d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle 44d4934a70e69365c97b1378820152e134a0089b5eCalin Juravleint nftw64(const char * dirpath, 45d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle int (*fn)(const char*, const struct stat64*, int, struct FTW*), 46d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle int nopenfd, int flags) { 47d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle return nftw(dirpath, reinterpret_cast<nftw_fn>(fn), nopenfd, flags); 48d4934a70e69365c97b1378820152e134a0089b5eCalin Juravle} 49