Introduce OakMoveToTrash and make it accessible only to C++

This is just a C++ wrapper around the Cocoa API for moving a file to trash.
This commit is contained in:
Ronald Wampler
2016-11-22 15:16:11 -05:00
committed by Allan Odgaard
parent b8143a626c
commit b9665fa44e
2 changed files with 21 additions and 0 deletions

View File

@@ -1,4 +1,15 @@
#ifndef OAKFOUNDATION_H_816ED92F
#define OAKFOUNDATION_H_816ED92F
#import <oak/misc.h>
#ifdef __cplusplus
PUBLIC std::string OakMoveToTrash (std::string const& path);
#endif
#ifdef __OBJC__
PUBLIC BOOL OakIsEmptyString (NSString* str);
PUBLIC BOOL OakNotEmptyString (NSString* str);
#endif
#endif /* end of include guard: OAKFOUNDATION_H_816ED92F */

View File

@@ -1,4 +1,14 @@
#import "OakFoundation.h"
#import "NSString Additions.h"
#import <ns/ns.h>
std::string OakMoveToTrash (std::string const& path)
{
NSURL* resultingItemURL;
if([[NSFileManager defaultManager] trashItemAtURL:[NSURL fileURLWithPath:[NSString stringWithCxxString:path]] resultingItemURL:&resultingItemURL error:nil])
return to_s([resultingItemURL path]);
else return NULL_STR;
}
BOOL OakIsEmptyString (NSString* str)
{