PageRenderTime 33ms CodeModel.GetById 12ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems-objc/LoopbackFS/loop.m

http://macfuse.googlecode.com/
Objective C | 66 lines | 35 code | 7 blank | 24 comment | 3 complexity | d45f1ec75f07f21af30ba5ba7da10b93 MD5 | raw file
 1// ================================================================
 2// Copyright (C) 2007 Google Inc.
 3// 
 4// Licensed under the Apache License, Version 2.0 (the "License");
 5// you may not use this file except in compliance with the License.
 6// You may obtain a copy of the License at
 7// 
 8//      http://www.apache.org/licenses/LICENSE-2.0
 9// 
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15// ================================================================
16//
17//  loop.m
18//  LoopbackFS
19//
20//  Created by ted on 12/30/07.
21//
22// This is a cmdline version of LoopbackFS. Compile as follows:
23//  gcc -o loop LoopbackFS.m loop.m -framework MacFUSE -framework Foundation
24//
25#import <Foundation/Foundation.h>
26#import <MacFUSE/GMUserFileSystem.h>
27#import "LoopbackFS.h"
28
29#define DEFAULT_MOUNT_PATH "/Volumes/loop"
30
31int main(int argc, char* argv[]) {
32  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
33
34  NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
35  NSString* rootPath = [args stringForKey:@"rootPath"];
36  NSString* mountPath = [args stringForKey:@"mountPath"];
37  if (!mountPath || [mountPath isEqualToString:@""]) {
38    mountPath = [NSString stringWithUTF8String:DEFAULT_MOUNT_PATH];
39  }
40  if (!rootPath) {
41    printf("\nUsage: %s -rootPath <path> [-mountPath <path>]\n", argv[0]);
42    printf("  -rootPath: Local directory path to mount, ex: /tmp\n");
43    printf("  -mountPath: Mount point to use. [Default='%s']\n",
44           DEFAULT_MOUNT_PATH);
45    printf("Ex: %s -rootPath /tmp -mountPath %s\n\n", argv[0], 
46           DEFAULT_MOUNT_PATH);
47    return 0;
48  }
49
50  LoopbackFS* loop = [[LoopbackFS alloc] initWithRootPath:rootPath];
51  GMUserFileSystem* userFS = [[GMUserFileSystem alloc] initWithDelegate:loop 
52                                                           isThreadSafe:YES];
53
54  NSMutableArray* options = [NSMutableArray array];
55  [options addObject:@"debug"];
56  [userFS mountAtPath:mountPath 
57          withOptions:options 
58     shouldForeground:YES 
59      detachNewThread:NO];
60
61  [userFS release];
62  [loop release];
63
64  [pool release];
65  return 0;
66}