/* 
 * File.java (Implements File Structure)
 *
 * Written by : Nitin  Motgi (nmotgi@cs.ucf.edu)
 * 
 * ASSUMPTIONS :
 *
 * 1. This program does not handle single line multi-level change 
 *    directory. (e.g. cd <dir-name> ... allowed, but
 *                     cd <dir-name1>/<dir-name2> ... not allowed.
 *
 * 2. All the operations that are done will be done in the
 *    directory pointed by currentDir.
 *
 * 3. The file/directory to be deleted should be owned by "me". If
 *    I don't own the file, then I cannot delete them.
 *
 * 4. The file or directory that you are thinking of deleting should
 *    be present in the current directory.
 *
 * 5. During recursive deletion of directory if there is any file or
 *    directory that is owned by some one else, the operation of 
 *    recursive deletion is aborted.
 *
 *
 * Portions copyright(c) 2001 to School of Electrical Engineering and 
 * Computer Science, UCF, Orlando.                   
 *                                    
 * Use and distribution of this source code are strictly governed by 
 * terms and conditions set by the authors.
 * 
 * $Id : File.java, 03/26/2001. $
 *            
 * Revision History:
 *
 * 1. Created basic structure           Nitin,        v1.0.0  04/02/2001.
 * 2. Added Documentation.              Nitin,        v1.0.1  04/02/2001.
*/

import java.io.*;
import java.util.*;

/* Class to handle files.*/
class File extends Component{ 
 public File(String szFileName,String szFileSize){
  this.szFileName = szFileName;
  this.szFileSize = szFileSize;
  this.szOwner    = "me";
  this.szGroup    = "us";
  szTime          = formatTime(System.currentTimeMillis());
  szPermissions   = "_rwxr_x__x";
 }/* End of Constructor.*/

 public String getOwner(){
  return szOwner;
 }/* End of getOwner.*/

 public String getPermissions(){
  return szPermissions;
 }/* End of getPermissions.*/

 public void operation() {
  System.out.println(szPermissions + "\t" + szOwner + "\t" + szGroup +
                    "\t" + szFileName);
 }/* End of operation.*/

 public boolean chown(String szNewOwn,String szName){
  if(szName.equals(szFileName) && szOwner.equals("me")){
   szOwner = szNewOwn; 
   return true;
  }/* End if.*/
  return false;
 }/* End of chown.*/

 public boolean chmod(String szMode,String szName){
  if(szName.equals(szFileName) && szOwner.equals("me")){
    szPermissions = "_";
    szPermissions = szPermissions + szMode;
    return true;
  }/* End if.*/
  return false;
 }/* End of chown.*/

 /* gets the file name.*/
 public String getName(){
  return szFileName;
 }/* End of getFileName.*/

 private int _identification;
 private String szFileName;
 private String szFileSize;
 private String szOwner;
 private String szGroup;
 private String szDate;
 private String szPermissions;
 private String szTime;
}/* End of file.*/

