Opened 14 years ago

Closed 11 years ago

#46 closed change (fixed (in master))

Create missing directories on startup

Reported by: takkaria Owned by: d_m
Milestone: 3.1.2 beta Keywords: cleanup


If we can, and if they're missing.

This will require portable "create directory" code. If we don't create them, a verbose explanation should be given of what the user must do to make the game work. The Windows port would benefit from this especially, as we could stop distributing files.

Change History (11)

comment:2 Changed 13 years ago by takkaria

  • component changed from Port-specific to Main game
  • Keywords port added

comment:3 Changed 13 years ago by takkaria

  • Milestone set to Future

comment:4 Changed 11 years ago by magnate

  • Keywords cleanup added; port removed

comment:5 Changed 11 years ago by magnate

  • Milestone changed from Future to 3.1.2 beta

Bringing this forward in the hope that this will fix the residual niggle from #134, to save me finding an alternative solution ...

comment:6 Changed 11 years ago by d_m

  • Owner set to d_m
  • Status changed from new to assigned

So, thanks to MarbleDice?'s testing, I think I can write some coding using mkdir() and stat() that will run on Windows and on POSIX systems. Which other platforms are we hoping to support?

Anyway, i will add the appropriate functions to z-file.c first and then talk to Magnate about how to proceed.

comment:7 Changed 11 years ago by d_m

As of [7395c6e] (SVN r1731) I have added dir_exists() and dir_create() which should be "cross-platform enough" for our purposes (windows and POSIX systems). dir_create() is recursive so hopefully it will prove useful.

I have tested these functions on Linux but I'd like to get more testing on Windows.

I'm leaving this bug open since these functions aren't actually *used* yet.

comment:8 Changed 11 years ago by magnate

The more I think about it, the more I think these functions should be called from just one place - in init2.c. All existing uses of mkdir occur there - the existing function is called create_user_dirs but it could be expanded to create_needed_dirs. It's currently called only by main.c and main-crb.c. Once we leave that function, we should have created all the dirs we'll ever need. The one possible exception is info/, which should only be created on the installation of spoilers - but I say that as a package manager, and if Takk wants the game to create info/ too that's fine with me - it's enough for me that it's not created by make install.

comment:9 Changed 11 years ago by magnate

In fact, I am having second thoughts about removing info/ from the install process. According to Debian policy it's actually ok to create empty dirs, if you expect users to put something in them. Unzipping spoiler files pretty clearly meets this expectation. So by all means let's include info/ in create_needed_dirs.

comment:10 Changed 11 years ago by magnate

  • Resolution set to fixed
  • Status changed from assigned to closed

[c99c742] (SVN r1733). I assumed that file/, edit/, pref/ and xtra/ will always need to exist, but it's easy enough to add them to create_needed_dirs if necessary. Now to tidy up the installation and get rid of the files.

comment:11 Changed 11 years ago by magnate

  • Resolution fixed deleted
  • Status changed from closed to reopened

[52ab8d5] (SVN r1734) removes the files, but we're not quite done yet:

games/angband: Cannot create /home/chrisc.angband/Angband

Need to check for the tilde expansion and avoid the extra slash.

comment:12 Changed 11 years ago by magnate

  • Resolution set to fixed
  • Status changed from reopened to closed

[b4a05a4] (SVN r1736).

Note: See TracTickets for help on using tickets.