client.m 2.67 KB
Newer Older
1 2 3
/*
 Project: FTP

4
 Copyright (C) 2005-2016 Free Software Foundation
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

 Author: Riccardo Mottola

 Created: 2005-04-21

 Generic client class, to be subclassed.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#import "client.h"

@implementation Client

/* initializer */
/* we set possibly unused stuff to NULL */
- (id)init
{
35 36 37 38 39
  if (!(self = [super init]))
    return nil;
  controller = nil;
  
  return self;
40 41 42 43
}

- (id)initWithController:(id)cont
{
44 45 46 47 48
  if (!(self = [super init]))
    return nil;
  controller = cont;
  
  return self;
49 50 51 52 53 54 55 56 57 58 59 60 61
}

- (void)dealloc
{
    if (homeDir)
        [homeDir release];
    if (workingDir)
        [workingDir release];
    if (workingDir)
        [workingDir release];
    [super dealloc];
}

62
- (bycopy NSString *)workingDir
63 64 65 66
{
    return workingDir;
}

67
- (bycopy NSString *)homeDir
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
{
    return homeDir;
}

- (void)setWorkingDirWithCString:(char *)dir
{
    [self setWorkingDir:[NSString stringWithCString:dir]];
}

- (void)setWorkingDir:(NSString *)dir
{
    if (workingDir)
        [workingDir release];
    workingDir = [[NSString stringWithString:dir] retain];
}

- (void)changeWorkingDir:(NSString *)dir
{
86
  [self setWorkingDir:dir];
87 88
}

89
- (bycopy NSArray *)workDirSplit
90
{
91 92 93 94 95 96 97 98 99 100 101 102
  NSMutableArray *reversedList;
  NSArray        *list;
  NSEnumerator   *en;
  NSString       *currElement;
  
  list = [workingDir pathComponents];
  
  
  reversedList = [NSMutableArray arrayWithCapacity:[list count]];
  en = [list reverseObjectEnumerator];
  while ((currElement = [en nextObject]))
    [reversedList addObject:currElement];
103
  return reversedList;
104 105
}

106
- (bycopy NSArray *)dirContents
107
{
108 109
  NSLog(@"override me! dirContents superclass method");
  return nil;
110 111 112 113
}

- (BOOL)createNewDir:(NSString *)dir
{
114 115
  NSLog(@"override me! createNewDir superclass method");
  return NO;
116 117
}

118
- (BOOL)deleteFile:(FileElement *)file beingAt:(int)depth
119
{
120
  NSLog(@"override me! deleteFile superclass method");
121
  return NO;
122 123
}

124 125 126 127 128 129
- (BOOL)renameFile:(FileElement *)file to:(NSString *)name
{
  NSLog(@"override me! renameFile superclass method");
  return NO;
}
 
130
@end