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

# fileDescriptorForPath:asLocalizedForLanguage:error:

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

## Declaration

```occ
- (int) fileDescriptorForPath:(NSString *) path asLocalizedForLanguage:(NSString *) languageIdentifier error:(NSError **) error;
```

## Parameters

- `path`: The relative path.
- `languageIdentifier`: The language, represented as a BCP-47 identifier, that the framework uses to limit the search within localized 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.

## Mentioned in

Reducing download and storage demands with localized asset packs

## 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 after you’re done using it. Use this method if you need low-level access to the file descriptor. If you don’t, then use contentsAtPath:asLocalizedForLanguage:options:error: instead. 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. This method searches in only the downloaded asset packs that are localized in the specified language. If there’s a file-path collision across multiple such asset packs, then it’s undefined from which asset pack the file will be read. This method is most useful if you intentionally induce a file-path collision across multiple differently localized asset packs. For example, you may include an English-localized version of Videos/Introduction.m4v in an en asset pack, a Hebrew-localized version of Videos/Introduction.m4v in a he asset pack, and an American Spanish–localized version of Videos/Introduction.m4v in an es-US asset pack. If you offer split-language functionality to users, then you may want to download two or more of those asset packs on the same device. In that scenario, the specific choice of file that fileDescriptorForPath:searchingInAssetPackWithIdentifier:error: opens would be undefined unless you determine the appropriate asset pack’s identifier and pass it to that method’s assetPackIdentifier parameter. With this method, merely passing a language identifier to the languageIdentifier parameter is sufficient to resolve the ambiguity without requiring that you determine the asset pack’s identifier. fileDescriptorForPath:searchingInAssetPackWithIdentifier:error: is more suitable in most other situations. note: Language matching considers implicit script and region tags per Unicode’s Common Locale Data Repository. For example, en is equivalent to en-US and en-Latn-US but not en-CA.

## 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:searchingInAssetPackWithIdentifier:error:](backgroundassets/baassetpackmanager/filedescriptorforpath:searchinginassetpackwithidentifier:error:.md)
- [URLForPath:error:](backgroundassets/baassetpackmanager/urlforpath:error:.md)
- [URLForPath:asLocalizedForLanguage:error:](backgroundassets/baassetpackmanager/urlforpath:aslocalizedforlanguage:error:.md)
