---
title: "fileDescriptorForPath:searchingInAssetPackWithIdentifier:error:"
framework: backgroundassets
role: symbol
role_heading: Instance Method
path: "backgroundassets/baassetpackmanager/filedescriptorforpath:searchinginassetpackwithidentifier:error:"
---

# fileDescriptorForPath:searchingInAssetPackWithIdentifier:error:

Opens and returns a file descriptor for the asset file at the specified relative path.

## Declaration

```occ
- (int) fileDescriptorForPath:(NSString *) path searchingInAssetPackWithIdentifier:(NSString *) assetPackIdentifier error:(NSError **) error;
```

## Parameters

- `path`: The relative file path.
- `assetPackIdentifier`: The identifier of the asset pack in which you want to search for the file or nil if you want to search in all asset packs.
- `error`: A pointer to an error that will be set if an error occurs. If no file is found at path, then it will point to an NSError object with doc://com.apple.backgroundassets/documentation/BackgroundAssets/BAManagedErrorCode/BAManagedErrorCodeFileNotFound as its code.

## Return Value

Return Value A descriptor for the opened file. A return value of -1 indicates that an error occurred.

## Discussion

Discussion important: It’s your responsibility to close the file descriptor when you’re done using it. All asset packs share the same namespace, so you can treat the overall collection of downloaded asset packs as if it were a single root directory that contains all of your subdirectories and asset files, regardless of the specific asset pack in which any particular file resides. If there’s a file-path collision across multiple asset packs, then it’s undefined from which asset pack the file will be opened unless you explicitly limit the search to a particular asset pack by passing a non-nil identifier to the assetPackIdentifier parameter. note: Use this method if you need low-level access to the file descriptor. If you don’t, then use contentsAtPath:searchingInAssetPackWithIdentifier:options:error: instead.

## See Also

### Accessing asset contents

- [contentsAtPath:searchingInAssetPackWithIdentifier:options:error:](backgroundassets/baassetpackmanager/contentsatpath:searchinginassetpackwithidentifier:options:error:.md)
- [contentsAtPath:asLocalizedForLanguage:options:error:](backgroundassets/baassetpackmanager/contentsatpath:aslocalizedforlanguage:options:error:.md)
- [fileDescriptorForPath:asLocalizedForLanguage:error:](backgroundassets/baassetpackmanager/filedescriptorforpath:aslocalizedforlanguage:error:.md)
- [URLForPath:error:](backgroundassets/baassetpackmanager/urlforpath:error:.md)
- [URLForPath:asLocalizedForLanguage:error:](backgroundassets/baassetpackmanager/urlforpath:aslocalizedforlanguage:error:.md)
