Files
gitx/PBEasyFS.m
T
Pieter de Bie e2b507313b Delete temporary files when they are deallocated
This will remove a lot of the stray files in the
temporary dir. However, they won't be deleted on exit
of the program. What to do about this?
2008-06-17 05:56:00 +02:00

32 lines
801 B
Objective-C

//
// PBEasyFS.m
// GitX
//
// Created by Pieter de Bie on 6/17/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "PBEasyFS.h"
@implementation PBEasyFS
+ (NSString*) tmpNameWithSuffix: (NSString*) path
{
NSString* newName = [NSString stringWithFormat: @"%@/XXXXXX%@", NSTemporaryDirectory(), path];
char *template = (char*) [newName fileSystemRepresentation];
int fd = mkstemps(template, [path length]);
close(fd);
return [NSString stringWithUTF8String:template];
}
+ (NSString*) tmpDirWithPrefix: (NSString*) path
{
NSString* newName = [NSString stringWithFormat: @"%@%@.XXXXXX", NSTemporaryDirectory(), path];
char *template = (char*) [newName fileSystemRepresentation];
template = mkdtemp(template);
return [NSString stringWithUTF8String:template];
}
@end