[Commits] [wesnoth/wesnoth] d06c39: Use delete_file() to delete reg files in config_ca...

GitHub noreply at github.com
Wed Dec 24 01:38:42 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: d06c39b714ef48e5e6dc96bc62a73c994f6e8c45
      https://github.com/wesnoth/wesnoth/commit/d06c39b714ef48e5e6dc96bc62a73c994f6e8c45
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2014-12-23 (Tue, 23 Dec 2014)

  Changed paths:
    M src/config_cache.cpp

  Log Message:
  -----------
  Use delete_file() to delete reg files in config_cache::delete_cache_files()

The reason is that, although both implementations of delete_directory()
can delete a regular file just fine, the Boost.filesystem implementation
depends upon a noisier implementation of get_files_in_dir(), which sends
an error message to stderr if the target is not a directory:

  20141223 21:54:36 error filesystem: Failed to open directory /home/shadowm/.wesnoth-1.13/cache/cache-v1.13.0-dev (cd02236-Modified)-aec97a1c3d958e534a2c379e200f91293932195b.gz: Not a directory
  20141223 21:54:36 error filesystem: Failed to open directory /home/shadowm/.wesnoth-1.13/cache/cache-v1.13.0-dev (cd02236-Modified)-b1a7724a622c9a107d2e5b70701d75e60db6ae4d.checksum.gz: Not a directory
  20141223 21:54:36 error filesystem: Failed to open directory /home/shadowm/.wesnoth-1.13/cache/cache-v1.13.0-dev (cd02236-Modified)-b1a7724a622c9a107d2e5b70701d75e60db6ae4d.gz: Not a directory

I really don't want to overcomplicate my code to deal with files and
directories separately, so I'm just sticking a check that incurs in an
extra stat() call for every entry to choose whether to use
delete_directory() or delete_file(). This is all very infrequently-run
code anyway, and modern OSes are smart.





More information about the Commits mailing list