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

issue JoelKatz opened this issue on July 26, 2011
  1. JoelKatz commented at 5:40 AM on July 26, 2011: contributor

    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.

  2. laanwj commented at 7:53 AM on March 31, 2014: member

    Fixed in master (2b7709dc84ed37128c125ca7a97b2e4b2c4437e7)

  3. laanwj closed this on Mar 31, 2014

  4. dexX7 referenced this in commit fd8049484d on Nov 19, 2016
  5. ptschip referenced this in commit bd00fc5664 on Apr 11, 2017
  6. jtimon referenced this in commit de842cb58f on Oct 17, 2018
  7. Losangelosgenetics referenced this in commit 1cf944cc52 on Mar 12, 2020
  8. rajarshimaitra referenced this in commit ea5758ae99 on Aug 5, 2021
  9. MarcoFalke locked this on Sep 8, 2021
  10. hebasto referenced this in commit 8d83f9c1d1 on Sep 29, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me