hawxgamer

get unc path matlab windows

Aug 8th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.18 KB | None | 0 0
  1. %----------------------------     GET_UNC_DRIVE       --------------------------
  2. % resolve windows drive letter to unc path
  3. %
  4. % usage:   unc_drive =  get_unc_drive(win_drive);
  5. % input:   win_drive -- drive name in windows style A:...Z:
  6. %        
  7. % output:  unc_drive
  8. % example:
  9. %     UNC = get_unc_drive('N:')
  10. %
  11. %-------------------------------------------------------------------------------
  12. function unc_drive = get_unc_drive(win_drive)
  13. unc_drive = '';
  14. [dummy, drivelist] = system('wmic logicaldisk get caption, drivetype, providername');
  15.  
  16. drivelist   = textscan(drivelist    ,...
  17.     '%s %d %s'                         ,...
  18.     'MultipleDelimsAsOne', true     ,...
  19.     'HeaderLines'        , 1        ,...
  20.     'Whitespace'         , ' \t\b\n'     );
  21.  
  22. win_drivelist = drivelist{1};
  23. drivetype     = drivelist{2};
  24. unc_drivelist = drivelist{3};
  25. posdrive      = strncmpi(win_drivelist, win_drive, length(win_drive));
  26. if any(posdrive)
  27.    if drivetype(posdrive)== 4
  28.       unc_drive     = unc_drivelist{posdrive};
  29.    else
  30.       fprintf('%s is not network-drive\n', win_drive)
  31.    end
  32. else
  33.    fprintf('%s drive does not exist\n', win_drive );
  34. end
Advertisement
Add Comment
Please, Sign In to add comment