[SOLVED] USB Drive lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- nhatdung · 2011-04-05 07:23 Hi! I'm currently porting my application to MacOS. I got two issue : + How to detect all usb drive ? + How to eject/safetly remove an USB Drive ? ---------------------------------------------------------------------- rajivsoft · 2011-04-05 08:10 you can call shell commands like 'ls /Volumes/' to see what is mounted on the system and 'umount /Volumes/desired_usb_name' to unmount for see ls output you must use TProcess and it's output property Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  ls_process: TProcess;  AStringList: TStringList;   begin      ls_process := TProcess.Create(nil);      ls_process.CommandLine := 'ls /Volumes/';      ls_process.Options := ls_process.Options + [poUsePipes, poWaitOnExit];      ls_process.Execute;         AStringList := TStringList.Create;      AStringList.LoadFromStream(ls_process.Output);... for umount you can use a simple Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Shell('mount /Volumes/' + desired_usb_name); ---------------------------------------------------------------------- nhatdung · 2011-04-05 10:15 hi! ls /Volumes/ seem work! It show me all USB drive include hdd drive. How to get exactly usb drive ? I can't umount any drive use the command : umount /Volumes/[drive name] it show me Operation not permitted BTW: How about umount drive with name have space on it (eg: "NO NAME") ? ---------------------------------------------------------------------- Bart · 2011-04-05 10:44 Un-mounting tipically needs root privileges, unless the current user mounted the volume (which seems likely for connecting USB devices). For spaces in names, you can probalby escape them with a "\", so something like this might work? Code: [Select]umount /Volumes/name\ with\ spaces Bart ---------------------------------------------------------------------- rajivsoft · 2011-04-05 10:53 Quote from: nhatdung on April 05, 2011, 12:15:42 pmhi! ls /Volumes/ seem work! It show me all USB drive include hdd drive. How to get exactly usb drive ?Try to use mount command to se what is mounted (i think usb drive mustn't have 'local' value in parenthesis, or something other different from hdd) QuoteI can't umount any drive use the command : umount /Volumes/[drive name] it show me Operation not permittedtry umount /Volumes/drive name/ (slash at the end) for me it works with a bash script that mount a specific folder of another mac on the network, then copy some files and at the end unmount the folder with umount... btw http://ss64.com/osx/mount.html ---------------------------------------------------------------------- nhatdung · 2011-04-05 16:04 Quote from: Bart on April 05, 2011, 12:44:05 pmUn-mounting tipically needs root privileges, unless the current user mounted the volume (which seems likely for connecting USB devices). For spaces in names, you can probalby escape them with a "\", so something like this might work? Code: [Select]umount /Volumes/name\ with\ spaces Bart I simply input a USB stick (4gb) and open terminal, trying to eject it but always got Operation not permitted (see attach file) And it seem like all have 'local' ---------------------------------------------------------------------- rajivsoft · 2011-04-05 16:22 Quote from: nhatdung on April 05, 2011, 06:04:17 pmI simply input a USB stick (4gb) and open terminal, trying to eject it but always got Operation not permitted (see attach file) And it seem like all have 'local' Try diskutil umount /Volumes/volume_name edit: but it has nosuid, now you can use mount to acquire all strings and then loop and seek with AnsiPos for it's presence, when it returns true that is your USB ---------------------------------------------------------------------- nhatdung · 2011-04-05 16:25 waoooooooo, work perfect! Thanks you! ---------------------------------------------------------------------- nhatdung · 2011-04-05 17:51 One more question:  how to shell open an url ? ---------------------------------------------------------------------- Leledumbo · 2011-04-05 18:02 QuoteOne more question:  how to shell open an url ?Err... LCLIntf.OpenURL? ---------------------------------------------------------------------- nhatdung · 2011-04-05 18:09 perfect