mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
e2b507313b
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?
32 lines
801 B
Objective-C
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
|