• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Find if mounted volume is Local or Network?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find if mounted volume is Local or Network?


  • Subject: Re: Find if mounted volume is Local or Network?
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 6 Nov 2009 11:02:04 -0800

Thank you all.  Indeed, statfs works.

Jerry


#import <sys/mount.h>

/*!
 @brief    Determines whether or not a the volume containing a
 given path is mounted locally or via a network connection.

 @details  Uses statfs
 @param    isLocal_p  Pointer which will, upon return, point
 to a BOOL indicating YES if the volume is mounted locally,
 NO if it is mounted via network connection.  Must not be NULL.
 @param    error_p  Pointer which will, upon return, if an error
 occurred and said pointer is not NULL, point to an NSError
 describing said error.
 @result   YES if the operation completed successfully,
 otherwise NO.
 */
+ (BOOL)path:(NSString*)path
   isLocal_p:(BOOL*)isLocal_p
     error_p:(NSError**)error_p ;

+ (BOOL)path:(NSString*)path
   isLocal_p:(BOOL*)isLocal_p
     error_p:(NSError**)error_p {
    BOOL ok = YES ;
    struct statfs aStatfs ;
    NSInteger statErr = statfs([path UTF8String], &aStatfs) ;
    if (statErr != 0) {
        ok = NO ;
        if (error_p) {
            *error_p = [NSError errorWithPosixErrorCode:errno] ;
        }
    }

    *isLocal_p = (aStatfs.f_flags & MNT_LOCAL) > 0 ;

    return ok ;
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Find if mounted volume is Local or Network? (From: Jerry Krinock <email@hidden>)
 >Re: Find if mounted volume is Local or Network? (From: Quinn <email@hidden>)
 >Re: Find if mounted volume is Local or Network? (From: Jim Luther <email@hidden>)

  • Prev by Date: Re: Find if mounted volume is Local or Network?
  • Next by Date: Re: Find if mounted volume is Local or Network?
  • Previous by thread: Re: Find if mounted volume is Local or Network?
  • Next by thread: Re: Find if mounted volume is Local or Network?
  • Index(es):
    • Date
    • Thread