Skip to content

Calls to filesystem::create_directory should be wrapped in try/catch blocks #432

@JoelKatz

Description

@JoelKatz

An error was reported using the bitcoin client with TrueCrypt:

EXCEPTION: N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_10filesystem
22basic_filesystem_errorINS3_10basic_pathISsNS3_11path_traitsEEEEEEEEE
boost::filesystem::create_directory: Permission Denied: "H:"
C:\Program Files (x86)\Bitcoin\bitcoin.exe in AppInit()

At least in some cases, it seems that a permission error can be returned when an attempt is made to create a directory that already exists if the caller wouldn't have permission to create the directory if it didn't exist. And in some cases, creating the data directory makes no logical sense, for example if the data directory is the root of a USB drive on a Windows system. In these cases, create_directory will throw an exception.

The client should put the create_directory calls in a try/catch block. If an exception is taken, the code should check if the directory exists and, if so, ignore the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions