-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFLDirectoryDataSource.m
56 lines (46 loc) · 1.06 KB
/
FLDirectoryDataSource.m
1
2
3
4
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Copyright (C) 1996 Dave Vasilevsky
* This file is licensed under the GNU General Public License,
* see the file Copying.txt for details. */
#import "FLDirectoryDataSource.h"
@implementation FLDirectoryDataSource
- (id) init
{
if (self = [super init]) {
m_rootDir = nil;
}
return self;
}
- (FLDirectory *) rootDir
{
return m_rootDir;
}
- (void) setRootDir: (FLDirectory *) root
{
[root retain];
if (m_rootDir) {
[m_rootDir release];
}
m_rootDir = root;
}
- (FLFile *) realItemFor: (id)item
{
return item ? item : m_rootDir;
}
- (id) child: (int)index ofItem: (id)item
{
FLFile *file = [self realItemFor: item];
return [[(FLDirectory *)file children] objectAtIndex: index];
}
- (int) numberOfChildrenOfItem: (id)item
{
FLFile *file = [self realItemFor: item];
return [file respondsToSelector: @selector(children)]
? [[(FLDirectory *)file children] count]
: 0;
}
- (float) weightOfItem: (id)item
{
FLFile *file = [self realItemFor: item];
return (float)[file size];
}
@end