CFURLAccess.pas 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. { CFURLAccess.h
  2. Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, November 2005 }
  5. {
  6. Modified for use with Free Pascal
  7. Version 200
  8. Please report any bugs to <[email protected]>
  9. }
  10. {$mode macpas}
  11. {$packenum 1}
  12. {$macro on}
  13. {$inline on}
  14. {$CALLING MWPASCAL}
  15. unit CFURLAccess;
  16. interface
  17. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  18. {$setc GAP_INTERFACES_VERSION := $0200}
  19. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  20. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  21. {$endc}
  22. {$ifc defined CPUPOWERPC and defined CPUI386}
  23. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  24. {$endc}
  25. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  26. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  27. {$endc}
  28. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  29. {$setc __ppc__ := 1}
  30. {$elsec}
  31. {$setc __ppc__ := 0}
  32. {$endc}
  33. {$ifc not defined __i386__ and defined CPUI386}
  34. {$setc __i386__ := 1}
  35. {$elsec}
  36. {$setc __i386__ := 0}
  37. {$endc}
  38. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  39. {$error Conflicting definitions for __ppc__ and __i386__}
  40. {$endc}
  41. {$ifc defined __ppc__ and __ppc__}
  42. {$setc TARGET_CPU_PPC := TRUE}
  43. {$setc TARGET_CPU_X86 := FALSE}
  44. {$elifc defined __i386__ and __i386__}
  45. {$setc TARGET_CPU_PPC := FALSE}
  46. {$setc TARGET_CPU_X86 := TRUE}
  47. {$elsec}
  48. {$error Neither __ppc__ nor __i386__ is defined.}
  49. {$endc}
  50. {$setc TARGET_CPU_PPC_64 := FALSE}
  51. {$ifc defined FPC_BIG_ENDIAN}
  52. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  53. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  54. {$elifc defined FPC_LITTLE_ENDIAN}
  55. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  56. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  57. {$elsec}
  58. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  59. {$endc}
  60. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  61. {$setc CALL_NOT_IN_CARBON := FALSE}
  62. {$setc OLDROUTINENAMES := FALSE}
  63. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  64. {$setc OPAQUE_UPP_TYPES := TRUE}
  65. {$setc OTCARBONAPPLICATION := TRUE}
  66. {$setc OTKERNEL := FALSE}
  67. {$setc PM_USE_SESSION_APIS := TRUE}
  68. {$setc TARGET_API_MAC_CARBON := TRUE}
  69. {$setc TARGET_API_MAC_OS8 := FALSE}
  70. {$setc TARGET_API_MAC_OSX := TRUE}
  71. {$setc TARGET_CARBON := TRUE}
  72. {$setc TARGET_CPU_68K := FALSE}
  73. {$setc TARGET_CPU_MIPS := FALSE}
  74. {$setc TARGET_CPU_SPARC := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_UNIX := FALSE}
  77. {$setc TARGET_OS_WIN32 := FALSE}
  78. {$setc TARGET_RT_MAC_68881 := FALSE}
  79. {$setc TARGET_RT_MAC_CFM := FALSE}
  80. {$setc TARGET_RT_MAC_MACHO := TRUE}
  81. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  82. {$setc TYPE_BOOL := FALSE}
  83. {$setc TYPE_EXTENDED := FALSE}
  84. {$setc TYPE_LONGLONG := TRUE}
  85. uses MacTypes,CFBase,CFArray,CFData,CFDictionary,CFString,CFURL;
  86. {$ALIGN POWER}
  87. { Attempts to read the data and properties for the given URL. If
  88. only interested in one of the resourceData and properties, pass NULL
  89. for the other. If properties is non-NULL and desiredProperties is
  90. NULL, then all properties are fetched. Returns success or failure;
  91. note that as much work as possible is done even if false is returned.
  92. So for instance if one property is not available, the others are
  93. fetched anyway. errorCode is set to 0 on success, and some other
  94. value on failure. If non-NULL, it is the caller 's responsibility
  95. to release resourceData and properties.
  96. Apple reserves for its use all negative error code values; these
  97. values represent errors common to any scheme. Scheme-specific error
  98. codes should be positive, non-zero, and should be used only if one of
  99. the predefined Apple error codes does not apply. Error codes should
  100. be publicized and documented with the scheme-specific properties.
  101. NOTE: When asking for the resource data, this call will allocate the entire
  102. resource in memory. This can be very expensive, depending on the size of the
  103. resource (file). Please use CFStream or other techniques if you are downloading
  104. large files.
  105. }
  106. function CFURLCreateDataAndPropertiesFromResource( alloc: CFAllocatorRef; url: CFURLRef; resourceData: CFDataRefPtr; properties: CFDictionaryRefPtr; desiredProperties: CFArrayRef; var errorCode: SInt32 ): Boolean; external name '_CFURLCreateDataAndPropertiesFromResource';
  107. { Attempts to write the given data and properties to the given URL.
  108. If dataToWrite is NULL, only properties are written out (use
  109. CFURLDestroyResource() to delete a resource). Properties not present
  110. in propertiesToWrite are left unchanged, hence if propertiesToWrite
  111. is NULL or empty, the URL's properties are not changed at all.
  112. Returns success or failure; errorCode is set as for
  113. CFURLCreateDataAndPropertiesFromResource(), above.
  114. }
  115. function CFURLWriteDataAndPropertiesToResource( url: CFURLRef; dataToWrite: CFDataRef; propertiesToWrite: CFDictionaryRef; var errorCode: SInt32 ): Boolean; external name '_CFURLWriteDataAndPropertiesToResource';
  116. { Destroys the resource indicated by url. }
  117. { Returns success or failure; errorCode set as above. }
  118. function CFURLDestroyResource( url: CFURLRef; var errorCode: SInt32 ): Boolean; external name '_CFURLDestroyResource';
  119. { Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). }
  120. { Returns NULL on error and sets errorCode accordingly. }
  121. function CFURLCreatePropertyFromResource( alloc: CFAllocatorRef; url: CFURLRef; proprty: CFStringRef; var errorCode: SInt32 ): CFTypeRef; external name '_CFURLCreatePropertyFromResource';
  122. { Common error codes; this list is expected to grow }
  123. type
  124. CFURLError = SInt32;
  125. const
  126. kCFURLUnknownError = -10;
  127. kCFURLUnknownSchemeError = -11;
  128. kCFURLResourceNotFoundError = -12;
  129. kCFURLResourceAccessViolationError = -13;
  130. kCFURLRemoteHostUnavailableError = -14;
  131. kCFURLImproperArgumentsError = -15;
  132. kCFURLUnknownPropertyKeyError = -16;
  133. kCFURLPropertyKeyUnavailableError = -17;
  134. kCFURLTimeoutError = -18;
  135. { Property keys }
  136. var kCFURLFileExists: CFStringRef; external name '_kCFURLFileExists'; (* attribute const *)
  137. var kCFURLFileDirectoryContents: CFStringRef; external name '_kCFURLFileDirectoryContents'; (* attribute const *)
  138. var kCFURLFileLength: CFStringRef; external name '_kCFURLFileLength'; (* attribute const *)
  139. var kCFURLFileLastModificationTime: CFStringRef; external name '_kCFURLFileLastModificationTime'; (* attribute const *)
  140. var kCFURLFilePOSIXMode: CFStringRef; external name '_kCFURLFilePOSIXMode'; (* attribute const *)
  141. var kCFURLFileOwnerID: CFStringRef; external name '_kCFURLFileOwnerID'; (* attribute const *)
  142. var kCFURLHTTPStatusCode: CFStringRef; external name '_kCFURLHTTPStatusCode'; (* attribute const *)
  143. var kCFURLHTTPStatusLine: CFStringRef; external name '_kCFURLHTTPStatusLine'; (* attribute const *)
  144. { The value of kCFURLFileExists is a CFBoolean }
  145. { The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty }
  146. { The value of kCFURLFileLength is a CFNumber giving the file's length in bytes }
  147. { The value of kCFURLFileLastModificationTime is a CFDate }
  148. { The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h }
  149. { The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid }
  150. { Properties for the http: scheme. Except for the common error codes, above, errorCode will be set to the HTTP response status code upon failure. Any HTTP header name can also be used as a property }
  151. { The value of kCFURLHTTPStatusCode is a CFNumber }
  152. { The value of kCFURLHTTPStatusLine is a CFString }
  153. end.