JX Application Framework
|
#include "jMountUtil.h"
#include "jDirUtil.h"
#include "JThisProcess.h"
#include "JRegex.h"
#include "JStringIterator.h"
#include "JStringMatch.h"
#include "jSysUtil.h"
#include <fstab.h>
#include <mntent.h>
#include "jAssert.h"
Functions | |
int | jUserOwnsDevice (const JString &name) |
bool | JGetUserMountPointList (JMountPointList *list, JMountState *state) |
JMountType | JGetUserMountPointType (const JString &path, const JString &device, const JString &fsType) |
bool | JIsMounted (const JString &path, bool *writable, bool *isTop, JString *device, JFileSystemType *fsType, JString *fsTypeString) |
bool | JFindUserMountPoint (const JString &path, const JMountPointList &list, JIndex *index) |
void | JMount (const JString &path, const bool mount, const bool block) |
void | jGetFullHostName (JString *host) |
bool | jCalledByTranslateLocalToRemote (const JString &localPath, const JUtf8Byte *mountDev, const JUtf8Byte *mountDir, bool *found, JString *host, JString *remotePath) |
bool | JTranslateLocalToRemote (const JString &localPathStr, JString *host, JString *remotePath) |
bool | jCalledByTranslateRemoteToLocal (const JString &host, const JString &remotePath, const JUtf8Byte *mountDev, const JUtf8Byte *mountDir, JString *localPath) |
bool | JTranslateRemoteToLocal (const JString &host, const JString &remotePathStr, JString *localPath) |
JError | JFormatPartition (const JString &path, const JString &type, JProcess **process) |
bool | JIsSamePartition (const JString &path1, const JString &path2) |
|
inline |
Translate local path to remote host and path, if it is mounted.
|
inline |
Translate remote host and path to local path, if it is mounted.
Note that this will not work if the remote path is a symbolic link. We can't convert that to a true path.
bool JFindUserMountPoint | ( | const JString & | path, |
const JMountPointList & | list, | ||
JIndex * | index | ||
) |
Returns true if the given path is on a mounted partition.
Erases the specified partition and converts it to the specified type.
Linux: ext2 DOS: msdos
Others may be supported on various systems.
Use with extreme caution!
|
inline |
bool JGetUserMountPointList | ( | JMountPointList * | list, |
JMountState * | state | ||
) |
JMountType JGetUserMountPointType | ( | const JString & | path, |
const JString & | device, | ||
const JString & | fsType | ||
) |
Returns the type of the specified mount point.
bool JIsMounted | ( | const JString & | path, |
bool * | writable, | ||
bool * | isTop, | ||
JString * | device, | ||
JFileSystemType * | fsType, | ||
JString * | fsTypeString | ||
) |
device can be nullptr
Returns true if the two directories are on the same partition.
To determine whether or not this function succeeded, call it with block=true and then check JIsMounted().
If mount = false, the file system is unmounted instead.
bool JTranslateRemoteToLocal | ( | const JString & | host, |
const JString & | remotePathStr, | ||
JString * | localPath | ||
) |
|
inline |
Returns a list of mount points and types that satisfy the following conditions:
spec path type opts ---- ---- ---- ---- / => always ignore swap => always ignore iso9660 => kJCDROM hd* => kJHardDisk (IDE) sd* => kJHardDisk (SCSI) fd* => kJFloppyDisk FreeBSD differences: cd9660 => kJCDROM ad* => kJHardDisk (IDE) da* => kJHardDisk (SCSI)
Sample macOS output:
/dev/disk1 on / (hfs, local, journaled) /dev/disk3s1 on /Volumes/XFER (msdos, local, nodev, nosuid, noowners) ntfs://disk4s1/NTFS on /Volumes/NTFS (lifs, local, nodev, nosuid, read-only, noowners, noatime)
Unless the current uid is zero (root), opts must include "user" or "users". The other possibility is that the device must be owned by the user, and opts must include "owner".
If state != nullptr, its value is compared with the mod time of /etc/fstab or equivalent. If the state is the same, nothing is done.
Returns true if /etc/fstab was read in, i.e., if state was nullptr or outdated.