ejectvolume

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - File handling
Introduced first in SolidGeometry 5.1, Creation date: 2021-03-07, Last change: 2025-09-15

Auxiliary fnct to unmount and eject a extrenal drive such as a sd card

Description

currently only available on mac

See Also: existvolume

Example Illustration

 missing image of ejectvolume(vnames)

Syntax

ejectvolume([vnames])

Input Parameter

vnames: name of voume or directory of volume

Examples


ejectvolume('/Volumes/AP5TIMLUETH')




Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, ejectvolume, is designed to unmount and eject an external drive, such as an SD card, on macOS systems. Below is a detailed explanation of the algorithm and its parameters.

Input Parameters

Algorithm Steps

  1. The function starts by defining a default list of volume names in the variable vnames. These are potential names for the volumes that might be ejected.
  2. The function getfuncparams is called with the arguments 1, varargin, and vnames. This function is assumed to process the input parameters and return the appropriate volume names to be used.
  3. The function checks if vnames is not a cell array and if the directory exists using exist(vnames, 'dir'). If true, it assigns vnames to dname.
  4. If the above condition is false, it calls the function existvolume with vnames to determine the directory name dname.
  5. The function checks if the system is a macOS using ismac and if dname is not empty.
  6. If both conditions are met, it constructs a system command scomm using sprintf to format the string 'diskutil eject %s' with dname.
  7. The system command scomm is executed using the system function, which attempts to eject the specified volume.

This function is specifically designed for macOS and relies on the diskutil command to perform the ejection of the volume.

Algorithm explaination created using ChatGPT on 2025-08-18 23:45. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21