/core/externals/update-engine/externals/google-toolbox-for-mac/Foundation/GTMNSFileHandle+UniqueName.h
C++ Header | 77 lines | 24 code | 12 blank | 41 comment | 0 complexity | ff9f1afb205bfd6f252f8ae9fbbae097 MD5 | raw file
1// 2// GTMNSFileHandle+UniqueName.h 3// 4// Copyright 2010 Google Inc. 5// 6// Licensed under the Apache License, Version 2.0 (the "License"); you may not 7// use this file except in compliance with the License. You may obtain a copy 8// of the License at 9// 10// http://www.apache.org/licenses/LICENSE-2.0 11// 12// Unless required by applicable law or agreed to in writing, software 13// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15// License for the specific language governing permissions and limitations under 16// the License. 17// 18 19#import <Foundation/Foundation.h> 20#import "GTMDefines.h" 21 22@interface NSFileHandle (GTMFileHandleUniqueNameAdditions) 23 24// Creates a read/write temporary file in NSTemporaryDirectory with mode 0600. 25// The template should be similar to the template passed to mkstemp. 26// If there is an extension on the nameTemplate it will remain. An example 27// template is "MyAppXXXXXX.txt". 28// If |path| is not nil, it will contain the derived path for the file. 29// The file descriptor wrapped by the NSFileHandle will be closed on dealloc. 30+ (id)gtm_fileHandleForTemporaryFileBasedOn:(NSString *)nameTemplate 31 finalPath:(NSString **)path; 32 33// Return an opened read/write file handle with mode 0600 based on a template. 34// The template should be similar to the template passed to mkstemp. 35// If there is an extension on the pathTemplate it will remain. An example 36// template is "/Applications/MyAppXXXXXX.txt". 37// If |path| is not nil, it will contain the derived path for the file. 38// The file descriptor wrapped by the NSFileHandle will be closed on dealloc. 39+ (id)gtm_fileHandleWithUniqueNameBasedOn:(NSString *)pathTemplate 40 finalPath:(NSString **)path; 41 42// Same as fileHandleWithUniqueNameBasedOn:finalName: but splits up the 43// template from the directory. 44+ (id)gtm_fileHandleWithUniqueNameBasedOn:(NSString *)nameTemplate 45 inDirectory:(NSString *)directory 46 finalPath:(NSString **)path; 47 48 49// Same as fileHandleWithUniqueNameBasedOn:inDirectory:finalName: but finds 50// the directory using the |directory| and |mask| arguments. 51+ (id)gtm_fileHandleWithUniqueNameBasedOn:(NSString *)nameTemplate 52 inDirectory:(NSSearchPathDirectory)directory 53 domainMask:(NSSearchPathDomainMask)mask 54 finalPath:(NSString **)path; 55@end 56 57@interface NSFileManager (GTMFileManagerUniqueNameAdditions) 58 59// Creates a new directory in NSTemporaryDirectory with mode 0700. 60// The template should be similar to the template passed to mkdtemp. 61- (NSString *)gtm_createTemporaryDirectoryBasedOn:(NSString *)nameTemplate; 62 63// Return the path to a directory with mode 0700 based on a template. 64// The template should be similar to the template passed to mkdtemp. 65- (NSString *)gtm_createDirectoryWithUniqueNameBasedOn:(NSString *)nameTemplate; 66 67// Same as createDirectoryWithUniqueNameBasedOn: but splits up the 68// template from the directory. 69- (NSString *)gtm_createDirectoryWithUniqueNameBasedOn:(NSString *)pathTemplate 70 inDirectory:(NSString *)directory; 71 72// Same as createDirectoryWithUniqueNameBasedOn:inDirectory: but finds 73// the directory using the |directory| and |mask| arguments. 74- (NSString *)gtm_createDirectoryWithUniqueNameBasedOn:(NSString *)pathTemplate 75 inDirectory:(NSSearchPathDirectory)directory 76 domainMask:(NSSearchPathDomainMask)mask; 77@end