Index: trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 17963)
+++ trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 17970)
@@ -1,5 +1,5 @@
 # Copyright (c) 2006  Paul Price, Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.88 2008-06-06 23:46:57 bills Exp $
+# $Id: Config.pm,v 1.89 2008-06-07 02:35:39 bills Exp $
 
 package PS::IPP::Config;
@@ -367,30 +367,45 @@
     my $self = shift;                # Configuration object
     my $name = shift;                # File name to check
-    my $touch = shift;                # if $name is in nebulous instantiate it
+    my $create_if_doesnt_exist = shift;
 
     my $scheme = file_scheme($name); # The scheme, e.g., file://, path://
 
-    return $name unless defined $scheme; # Probably a file name instead of a URI
-    $scheme = lc($scheme);
-
-    if ($scheme eq 'neb') {
-        $self->_neb_start();
-        my $neb = $self->{nebulous}; # Nebulous handle
-        if ($touch) {
-            unless ($neb->stat( $name )) {
-                my $uri = $neb->create( $name );
-                unless(defined $uri) {
-                    carp "unable to instantiate $name.";
-                    exit($PS_EXIT_DATA_ERROR);
+    if ($scheme) {
+        $scheme = lc($scheme);
+
+        if ($scheme eq 'neb') {
+            $self->_neb_start();
+            my $neb = $self->{nebulous}; # Nebulous handle
+            if ($create_if_doesnt_exist) {
+                unless ($neb->stat( $name )) {
+                    my $uri = $neb->create( $name );
+                    unless(defined $uri) {
+                        carp "unable to instantiate $name.";
+                        exit($PS_EXIT_DATA_ERROR);
+                    }
+                    my $path = URI->new( $uri )->path;
+                    return $path;
                 }
-                my $path = URI->new( $uri )->path;
-                return $path;
             }
-        }
-        return $neb->find( $name );
-    }
-    if ($scheme eq 'path' or $scheme eq 'file') {
-        # guaranteed to have a scheme (path:// or file://)
-        return $self->convert_filename_absolute( $name );
+            return $neb->find( $name );
+        }
+        if ($scheme eq 'path' or $scheme eq 'file') {
+            # guaranteed to have a scheme (path:// or file://)
+            $name = $self->convert_filename_absolute( $name );
+        }
+    }
+
+    if ($create_if_doesnt_exist && ! -e $name) {
+        # make sure the file's parent directory exists
+        my $dir = dirname($name);
+        if (! -e $dir) {
+            my $rc = system "mkdir -p $dir";
+            die "failed to create directory for $name" unless (!$rc);
+        } elsif (! -d $dir ) {
+            die "parent for $name exists and is not a directory";
+        }
+
+        open F, ">$name" or die "failed to create $name";
+        close F;
     }
 
@@ -552,16 +567,7 @@
     die "need name" unless $name;
 
-    my $filename = $self->file_resolve($name, "--touch");
+    my $filename = $self->file_resolve($name, 1);
 
     die "cannot resolve $name" unless $filename;
-
-    # We need to make sure the directory for this file exists
-    # If it's a nebulous file it has already been created so the directory must exist
-    # we won't run mkdir there
-    my $dir = dirname($filename);
-    if (! -d $dir) {
-        my $rc = system "mkdir -p $dir";
-        die "failed to create directory for $filename" unless (!$rc);
-    }
 
     open STDOUT, ">>$filename" or die "failed to redirect stdout to $filename";
