source: trunk/SapphireFrappliance/main_rescanDir.m @ 1205

Revision 1205, 2.1 KB checked in by gbooker, 4 years ago (diff)

Changed all [pool release] to [pool drain].

Line 
1/*
2 * main_rescanDir.m
3 * Sapphire
4 *
5 * Created by Graham Booker on Nov. 30, 2008.
6 * Copyright 2008 Sapphire Development Team and/or www.nanopi.net
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License as published by the Free Software Foundation; either version 3 of the License,
11 * or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15 * Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with this program; if not,
18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 */
20
21#include "../SapphireCompatibilityClasses/Sapphire_Prefix.pch"
22#import "FRAppliance/SapphireApplianceController.h"
23
24int main(int argc, char *argv[])
25{
26        if(argc < 1)
27        {
28                printf("Usage: %s directory", argv[0]);
29                return 1;
30        }
31       
32        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
33        int i, ret = 0;
34        NSFileManager *fm = [NSFileManager defaultManager];
35        for(i=1; i<argc; i++)
36        {
37                NSString *path = [fm stringWithFileSystemRepresentation:argv[i] length:strlen(argv[i])];
38                path = [path stringByStandardizingPath];
39                if(![path isAbsolutePath])
40                        path = [[fm currentDirectoryPath] stringByAppendingPathComponent:path];
41                BOOL isDir = NO;
42                if([fm fileExistsAtPath:path isDirectory:&isDir] && isDir)
43                {
44                        NSPort *sendPort = [[NSSocketPort alloc] initRemoteWithTCPPort:DISTRIBUTED_MESSAGES_PORT host:@"127.0.0.1"];
45                        NSConnection *conn = [[NSConnection alloc] initWithReceivePort:[NSSocketPort port] sendPort:sendPort];
46                        [sendPort release];
47                        id proxy = [conn rootProxy];
48                        [proxy setProtocolForProxy:@protocol(SapphireDistributedMessagesProtocol)];
49                        [(id <SapphireDistributedMessagesProtocol>)proxy rescanDirectory:path];
50                        [conn release];
51                }
52                else
53                {       
54                        printf("%s is not a directory", argv[i]);
55                        ret = 1;
56                }
57        }
58        [pool drain];
59        return ret;
60}
Note: See TracBrowser for help on using the repository browser.