12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2009 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_OS_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_OS_H_ 19db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 20761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughesnamespace unix_file { 21761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughesclass FdFile; 22761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes} // namespace unix_file 23761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes 24db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstromnamespace art { 25db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 26761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughestypedef ::unix_file::FdFile File; 27db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 28761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes// Interface to the underlying OS platform. 29db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 30db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstromclass OS { 31db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom public: 327571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom // Open an existing file with read only access. 337571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom static File* OpenFileForReading(const char* name); 347571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom 357571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom // Open an existing file with read/write access. 367571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom static File* OpenFileReadWrite(const char* name); 377571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom 38b73f1f580d50b5f0792ec99c22a0eb4b355d7012Andreas Gampe // Create an empty file with read/write access. This is a *new* file, that is, if the file 39b73f1f580d50b5f0792ec99c22a0eb4b355d7012Andreas Gampe // already exists, it is *not* overwritten, but unlinked, and a new inode will be used. 407571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom static File* CreateEmptyFile(const char* name); 417571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom 42f83e733618066e3c672c9a7ee872a3bba8202e7fCalin Juravle // Create an empty file with write access. This is a *new* file, that is, if the file 43f83e733618066e3c672c9a7ee872a3bba8202e7fCalin Juravle // already exists, it is *not* overwritten, but unlinked, and a new inode will be used. 44f83e733618066e3c672c9a7ee872a3bba8202e7fCalin Juravle static File* CreateEmptyFileWriteOnly(const char* name); 45f83e733618066e3c672c9a7ee872a3bba8202e7fCalin Juravle 467571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom // Open a file with the specified open(2) flags. 477571e8b761ebc2c923525e12ea9fcf07e62cb33eBrian Carlstrom static File* OpenFileWithFlags(const char* name, int flags); 48db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 49db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom // Check if a file exists. 50db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom static bool FileExists(const char* name); 51161928613d3f097108319de60494fab1aab8d48aBrian Carlstrom 52161928613d3f097108319de60494fab1aab8d48aBrian Carlstrom // Check if a directory exists. 53161928613d3f097108319de60494fab1aab8d48aBrian Carlstrom static bool DirectoryExists(const char* name); 54db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom}; 55db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 56db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom} // namespace art 57db4d54081f09abcbe97ffdf615874f2809a9e777Brian Carlstrom 58fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_OS_H_ 59