package com.csc.library.drive;

import com.csc.library.mail.SendMail;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.utilities.MyLog;

public class LinuxMapDrive  extends BaseMapDrive {
	
	public LinuxMapDrive() {
		havedrive=false;
		initEnv();		
		mapDrive=this;
	}
	
	/**
	 * mount -t smbfs //servername/share /mnt/mountpoint
	 */
	@Override	
	public boolean mapDrive(String drive, String path, String user, String pwd)
			throws Exception { //�ѧ�������� �����ѧ���������ͧ�ͧ
		return super.mapDrive(drive, path, user, pwd);
	}
	
	public boolean scanDrive() throws Exception {
		if(havedrive){
			if(this.canRead(drive+":/")){
				return true;
			}else{
				if(this.mapDrive(drive, path, user, pwd)){
					return true;
				}else{
					MyLog.error(this,"Can't not connect map drive, please check map drive");
					String from =new InitialEnvironment("GLOBAL").getValue("MAILAUTH-username");
					String subject="Please check map drive on server myhr";
					InitialEnvironment env=new InitialEnvironment("GLOBAL");
					String content="Can't not connect map drive, please check drive ["+drive+"] on server "+env.getValue("server-provider_url");
					SendMail sm=new SendMail("",from,from, "", subject,content);
							 sm.send();
					throw new Exception("Can't not connect map drive, please check map drive");
				}
			}
		}else{
			return true;
		}
	}

}