Created
May 26, 2011 19:46
-
-
Save anonymous/993905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just for my reference i am keeping it as following: | |
===================================================== | |
private var os:String; | |
private var consoleExecutable:File; | |
private var consoleNativeProcess:NativeProcess; | |
private function usbMounted(e:StorageVolumeChangeEvent):void { | |
//status.appendText('Device: ' + e.storageVolume.name + ' mounted to drive: ' + e.storageVolume.drive + '\n'); | |
os = Capabilities.os.substr(0, 3).toLowerCase(); | |
switch (os) | |
{ | |
case "win"://Windows OS | |
var rootDirs:Array = File.getRootDirectories(); | |
var i:int = 0; | |
for (i; i < rootDirs.length; ++i) { | |
consoleExecutable = rootDirs[i] as File; | |
consoleExecutable = consoleExecutable.resolvePath("Windows"); | |
if (consoleExecutable.exists == true) { | |
consoleExecutable = consoleExecutable.resolvePath("System32"); | |
consoleExecutable = consoleExecutable.resolvePath("cmd.exe"); | |
i = rootDirs.length; | |
} | |
} | |
break; | |
case "lin": //Linux OS break; | |
case "mac": //Mac OS break; | |
case "iph": //Iphone OS break; | |
} | |
var consoleNativeProcessStartupNfo:NativeProcessStartupInfo = new NativeProcessStartupInfo(); | |
consoleNativeProcessStartupNfo.executable = consoleExecutable; | |
var startupArgs:Vector.<String> = new Vector.<String>(); | |
startupArgs.push('/C fsutil fsinfo volumeinfo ' + e.storageVolume.drive + ':'); | |
consoleNativeProcessStartupNfo.arguments = startupArgs; | |
consoleNativeProcess = new NativeProcess(); | |
consoleNativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, consoleOutput); | |
consoleNativeProcess.start(consoleNativeProcessStartupNfo); | |
consoleNativeProcess.closeInput(); | |
} | |
private function consoleOutput(e:ProgressEvent):void { | |
var consoleOuput:String = consoleNativeProcess.standardOutput.readUTFBytes(consoleNativeProcess.standardOutput.bytesAvailable); | |
switch (os) { | |
case "win": //Windows OS break; | |
case "lin": //Linux OS break; | |
case "mac": //Mac OS break; | |
case "iph": //Iphone OS break; | |
} | |
consoleNativeProcess.exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment