commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/example Shell.java
Date Mon, 17 Mar 2003 09:07:55 GMT
adammurdoch    2003/03/17 01:07:55

  Modified:    vfs/src/java/org/apache/commons/vfs/example Shell.java
  Log:
  Added 'touch' command to example.
  
  Revision  Changes    Path
  1.2       +21 -1     jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/example/Shell.java
  
  Index: Shell.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/example/Shell.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Shell.java	21 Feb 2003 05:15:51 -0000	1.1
  +++ Shell.java	17 Mar 2003 09:07:55 -0000	1.2
  @@ -163,6 +163,10 @@
           {
               rm( cmd );
           }
  +        else if ( cmdName.equalsIgnoreCase( "touch" ) )
  +        {
  +            touch( cmd );
  +        }
           else
           {
               System.err.println( "Unknown command \"" + cmdName + "\"." );
  @@ -180,6 +184,7 @@
           System.out.println( "ls [-R] [folder]   Lists contents of a folder." );
           System.out.println( "pwd                Displays current folder." );
           System.out.println( "rm <path>          Deletes a file or folder." );
  +        System.out.println( "touch <path>       Sets the last-modified time of a
file." );
       }
   
       /** Does an 'rm' command. */
  @@ -280,6 +285,21 @@
           // List the contents
           System.out.println( "Contents of " + dir.getName() );
           listChildren( dir, recursive, "" );
  +    }
  +
  +    /** Does a 'touch' command. */
  +    private void touch( final String[] cmd ) throws Exception
  +    {
  +        if ( cmd.length < 2 )
  +        {
  +            throw new Exception( "USAGE: touch <path>" );
  +        }
  +        final FileObject file = mgr.resolveFile( cwd, cmd[ 1 ] );
  +        if ( !file.exists() )
  +        {
  +            file.createFile();
  +        }
  +        file.getContent().setLastModifiedTime( System.currentTimeMillis() );
       }
   
       /** Lists the children of a folder. */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message