Contents

LSSetExtensionHiddenForURL(_:_:)

Specifies whether to show or hide the filename extension for an item with a URL.

Declaration

func LSSetExtensionHiddenForURL(_ inURL: CFURL!, _ inHide: Bool) -> OSStatus

Parameters

  • inFileURL:

    A Core Foundation URL reference designating the item whose filename extension is to be hidden or shown; see the CFURL Reference in the Core Foundation Reference Documentation for a description of the CFURLRef data type. The URL must have scheme file and contain a valid path to either a file or a directory.

  • inHide:

    A Boolean value specifying whether the extension should be hidden (true) or shown (false).

Return Value

A result code; see Result Codes. The function will return the result code kLSCannotSetInfoErr if:

  • The extension is not valid (contains spaces)

  • The extension is not active (is not claimed by an application registered with Launch Services)

  • Hiding the extension would make the filename appear to have an active but incorrect extension (for example, in the filename Photo.jpeg.scpt, where hiding the extension would make an AppleScript file appear to be a JPEG file)

Discussion

This function sets the necessary file-system state controlling whether the filename extension should be hidden in the display name of the item designated by the inFileURL parameter. To determine whether an item’s extension is currently hidden, you can use the LSCopyItemInfoForURL function.

Version-Notes

Thread-safe since Mac OS version 10.2.

See Also

Deprecated Functions