Package com.zaranux.os.client.commands

Source Code of com.zaranux.os.client.commands.mkdir

package com.zaranux.os.client.commands;

import com.zaranux.client.api.AsyncCallback;
import com.zaranux.client.java.io.File;
import com.zaranux.client.java.io.PrintStream;

import com.zaranux.os.client.util.Log;

/**
*
* @author Arona <summary> This Class is command for making directory.
*         </summary> <version>$Revision$ $Date$</version> <history>
*         <record>09/25/2009. Arona - created this file</record>
*         <record>09/28/2009. Arona - Changing parameter</record> </history>
*/
public class mkdir extends Command {

  @Override
  protected void execute(final AsyncCallback<Boolean> callback) {
    String[] args = getArgs();
    String name = args[0];
    String dir = getCurrentDirectory(); // current directory
     
    File f= new File(dir);
   
      f.mkdir(new AsyncCallback<Boolean>() {

        public void onFailure(Throwable T) {
          System.out.print( "making new directory failed.", callback );
        }

        public void onSuccess(final Boolean b) {         
          if (b) {// creating folder
            callback.onSuccess(true);
          } else
            System.out.print("making new directory failed.", callback);
          }
      });

    /*} else {
      final StringBuffer result = new StringBuffer();
      final PrintStream outPS = (PrintStream) System.out;
      result.append("FAILED: wrong parametere.");
      // show message on terminal
      outPS.print(result.toString(), new AsyncCallback<Boolean>() {
        public void onSuccess(Boolean b) {
          // outPS.flush(callback);
          callback.onSuccess(b);
        }

        public void onFailure(Throwable t) {
          callback.onFailure(t);
        }
      });
    }*/

  }

}
 
TOP

Related Classes of com.zaranux.os.client.commands.mkdir

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.