Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
DirectoryTool - Commitdiff - ViewGit - Blue Static

Adding -[BSDirectoryRecord name] to get the name of a record

Robert Sesek [2007-11-23 02:52]
Adding -[BSDirectoryRecord name] to get the name of a record
diff --git a/Source/AppController.m b/Source/AppController.m
index b4e3e3e..5410d78 100755
--- a/Source/AppController.m
+++ b/Source/AppController.m
@@ -32,6 +32,7 @@
 		{
 			for (BSDirectoryRecord *record in [node records])
 			{
+				NSLog(@"record name = %@", [record name]);
 				[record attributes];
 			}
 		}
diff --git a/Source/BSDirectoryNode.m b/Source/BSDirectoryNode.m
index 336b4e4..3ac56a2 100755
--- a/Source/BSDirectoryNode.m
+++ b/Source/BSDirectoryNode.m
@@ -128,10 +128,7 @@
 			continue;
 		}

-		[records addObject:[[BSDirectoryRecord alloc] initWithRecord:record
-													  withAttributes:attributeList
-															  inNode:self]];
-		break;
+		[records addObject:[[BSDirectoryRecord alloc] initWithRecord:record withAttributes:attributeList inNode:self]];
 	}

 	NSLog(@"records = %@", records);
diff --git a/Source/BSDirectoryRecord.h b/Source/BSDirectoryRecord.h
index 351c0b5..8d9f622 100755
--- a/Source/BSDirectoryRecord.h
+++ b/Source/BSDirectoryRecord.h
@@ -36,6 +36,7 @@
 	  withAttributes:(tAttributeListRef)attribs
 			  inNode:(BSDirectoryNode *)aNode;

+- (NSString *)name;
 - (NSDictionary *)attributes;

 // TEMPORARY
diff --git a/Source/BSDirectoryRecord.m b/Source/BSDirectoryRecord.m
index ff00a8e..cf41e21 100755
--- a/Source/BSDirectoryRecord.m
+++ b/Source/BSDirectoryRecord.m
@@ -66,6 +66,23 @@
 }

 /**
+ * Gets the records name
+ */
+- (NSString *)name
+{
+	char *name = NULL;
+	tDirStatus status = dsGetRecordNameFromEntry(record, &name);
+	if (status != eDSNoErr)
+	{
+		NSLog(@"error getting name = %i", status);
+		return nil;
+	}
+	NSString *namestr = [NSString stringWithUTF8String:name];
+	free(name);
+	return namestr;
+}
+
+/**
  * Gets an NSDictionary of all the attributes a record has
  */
 - (NSDictionary *)attributes