+sub setstatedir {
+ my $dirorsetup=shift;
+
+ if (! defined $dirorsetup) {
+ usage();
+ }
+
+ if (-d $dirorsetup) {
+ $config{wikistatedir}=$dirorsetup."/.ikiwiki";
+ }
+ elsif (-f $dirorsetup) {
+ loadsetup($dirorsetup);
+ }
+ else {
+ error("ikiwiki-transition: $dirorsetup does not exist");
+ }
+
+ if (! -d $config{wikistatedir}) {
+ error("ikiwiki-transition: $config{wikistatedir} does not exist");
+ }
+}
+
+sub loadsetup {
+ my $setup=shift;
+ if (! defined $setup) {
+ usage();
+ }
+
+ require IkiWiki::Setup;
+
+ %config = IkiWiki::defaultconfig();
+ IkiWiki::Setup::load($setup);
+}
+