So apparently we have to open records in order to access their information

Robert Sesek [2007-11-07 14:06]
So apparently we have to open records in order to access their information
diff --git a/Source/AppController.m b/Source/AppController.m
index b7eb952..e5aa2c2 100644
--- a/Source/AppController.m
+++ b/Source/AppController.m
@@ -31,7 +31,7 @@
 	{
 		NSLog(@"node = %@", [node name]);
 		[node open];
-		[node attributes];
+		//[node attributes];
 		for (BSDirectoryRecord *record in [node records])
 		{
 			[record attributes];
diff --git a/Source/BSDirectoryNode.m b/Source/BSDirectoryNode.m
index 67af079..9c883a2 100644
--- a/Source/BSDirectoryNode.m
+++ b/Source/BSDirectoryNode.m
@@ -103,13 +103,13 @@
 	}

 	tDataList recordTypes;
-	if (dsBuildListFromStringsAlloc(dirRef, &recordTypes, kDSRecordsAll, NULL) != eDSNoErr)
+	if (dsBuildListFromStringsAlloc(dirRef, &recordTypes, kDSStdRecordTypeAll, NULL) != eDSNoErr)
 	{
 		NSLog(@"could not allocate record types list");
 	}

 	tDataList attributesTypes;
-	if (dsBuildListFromStringsAlloc(dirRef, &attributesTypes, kDSAttributesStandardAll, NULL) != eDSNoErr)
+	if (dsBuildListFromStringsAlloc(dirRef, &attributesTypes, kDSAttributesAll, NULL) != eDSNoErr)
 	{
 		NSLog(@"could not allocate attribute types list");
 	}
diff --git a/Source/BSDirectoryRecord.h b/Source/BSDirectoryRecord.h
index 7bc14df..5d9f4e0 100644
--- a/Source/BSDirectoryRecord.h
+++ b/Source/BSDirectoryRecord.h
@@ -24,6 +24,7 @@
 	tDirNodeReference nodeRef;
 	tDirReference dirRef;
 	tRecordEntry *record;
+	tRecordReference recordRef;
 	tAttributeListRef attributesRef;

 	NSMutableDictionary *attributes;
@@ -35,6 +36,8 @@
 			 withRef:(tDirNodeReference)aNodeRef
 		 inDirectory:(tDirReference)aDirRef;

+- (void)open;
+
 - (NSDictionary *)attributes;

 @end
diff --git a/Source/BSDirectoryRecord.m b/Source/BSDirectoryRecord.m
index 2689d01..26e301c 100644
--- a/Source/BSDirectoryRecord.m
+++ b/Source/BSDirectoryRecord.m
@@ -47,35 +47,57 @@
 	dsCloseAttributeList(attributesRef);
 	dsDeallocRecordEntry(dirRef, record);

+	if (recordRef)
+	{
+		dsCloseRecord(recordRef);
+	}
+
 	[super finalize];
 }

 /**
+ * Opens a record for work
+ */
+- (void)open
+{
+	NSLog(@"open record: '%i'", record->fRecordNameAndType.fBufferSize); return;
+	if (dsOpenRecord(dirRef, NULL, NULL, &recordRef) != eDSNoErr)
+	{
+		NSLog(@"could not open record %s", record->fRecordNameAndType);
+	}
+}
+
+/**
  * Gets an NSDictionary of all the attributes a record has
  */
 - (NSDictionary *)attributes
 {
-	tDataBuffer *buffer = dsDataBufferAllocate(dirRef, 3 * 1024);
+	tDataBufferPtr buffer = dsDataBufferAllocate(dirRef, 3 * 1024);

+	[self open];
+
+	return nil;
+
+	tDataNodePtr types = dsDataNodeAllocateString(dirRef, kDSAttributesAll);
+
 	unsigned long i = 1;
 	for ( ; i <= record->fRecordAttributeCount; i++)
 	{
-		tAttributeValueListRef valueListRef = 0;
 		tAttributeEntryPtr infoRef = 0;
-		dsGetAttributeEntry(nodeRef, buffer, attributesRef, i, &valueListRef, &infoRef);
+		NSLog(@"dsGetAttributeEntry status = %i", dsGetRecordAttributeInfo(recordRef, types, &infoRef));

 		unsigned long j = 1;
 		for ( ; j <= infoRef->fAttributeValueCount; j++)
 		{
 			tAttributeValueEntryPtr valueRef;
-			dsGetAttributeValue(nodeRef, buffer, j, valueListRef, &valueRef);
+			//dsGetAttributeValue(nodeRef, buffer, j, valueListRef, &valueRef);

 			NSLog(@"%s : %i", valueRef->fAttributeValueData, valueRef->fAttributeValueID);

 			dsDeallocAttributeValueEntry(dirRef, valueRef);
 		}

-		dsCloseAttributeValueList(valueListRef);
+		//dsCloseAttributeValueList(valueListRef);
 		dsDeallocAttributeEntry(dirRef, infoRef);
 	}