-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from kishikawakatsumi/freespace
Added function to check free space on shared drives
- Loading branch information
Showing
9 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Sources/SMBClient/Messages/FileSystemInformationClasses/FileFsDeviceInformation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Foundation | ||
|
||
public struct FileFsDeviceInformation { | ||
public let deviceType: UInt32 | ||
public let characteristics: Characteristics | ||
|
||
public enum DeviceType: UInt32 { | ||
case cdRom = 0x00000002 | ||
case disk = 0x00000007 | ||
} | ||
|
||
public struct Characteristics: OptionSet { | ||
public let rawValue: UInt32 | ||
|
||
public init(rawValue: UInt32) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
public static let removableMedia = Characteristics(rawValue: 0x00000001) | ||
public static let readOnlyDevice = Characteristics(rawValue: 0x00000002) | ||
public static let floppyDiskette = Characteristics(rawValue: 0x00000004) | ||
public static let writeOnceMedia = Characteristics(rawValue: 0x00000008) | ||
public static let remoteDevice = Characteristics(rawValue: 0x00000010) | ||
public static let deviceIsMounted = Characteristics(rawValue: 0x00000020) | ||
public static let virtualVolume = Characteristics(rawValue: 0x00000040) | ||
public static let deviceSecureOpen = Characteristics(rawValue: 0x00000100) | ||
public static let characteristicTsDevice = Characteristics(rawValue: 0x00001000) | ||
public static let characteristicWebDavDevice = Characteristics(rawValue: 0x00002000) | ||
public static let deviceAllowAppContainerTraversal = Characteristics(rawValue: 0x00020000) | ||
public static let portableDevice = Characteristics(rawValue: 0x00004000) | ||
} | ||
|
||
public init(data: Data) { | ||
let reader = ByteReader(data) | ||
|
||
deviceType = reader.read() | ||
characteristics = Characteristics(rawValue: reader.read()) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Sources/SMBClient/Messages/FileSystemInformationClasses/FileFsLabelInformation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
|
||
public struct FileFsLabelInformation { | ||
public let volumeLabelLength: UInt32 | ||
public let volumeLabel: String | ||
|
||
public init(data: Data) { | ||
let reader = ByteReader(data) | ||
|
||
volumeLabelLength = reader.read() | ||
let volumeLabelData = reader.read(count: Int(volumeLabelLength)) | ||
volumeLabel = String(data: volumeLabelData, encoding: .utf16LittleEndian) ?? volumeLabelData.hex | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SMBClient/Messages/FileSystemInformationClasses/FileFsSizeInformation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Foundation | ||
|
||
public struct FileFsSizeInformation { | ||
public let totalAllocationUnits: UInt64 | ||
public let availableAllocationUnits: UInt64 | ||
public let sectorsPerAllocationUnit: UInt32 | ||
public let bytesPerSector: UInt32 | ||
|
||
public init(data: Data) { | ||
let reader = ByteReader(data) | ||
|
||
totalAllocationUnits = reader.read() | ||
availableAllocationUnits = reader.read() | ||
sectorsPerAllocationUnit = reader.read() | ||
bytesPerSector = reader.read() | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Sources/SMBClient/Messages/FileSystemInformationClasses/FileFsVolumeInformation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
|
||
public struct FileFsVolumeInformation { | ||
public let volumeCreationTime: UInt64 | ||
public let volumeSerialNumber: UInt32 | ||
public let volumeLabelLength: UInt32 | ||
public let supportsObjects: Bool | ||
public let reserved: UInt8 | ||
public let volumeLabel: String | ||
|
||
public init(data: Data) { | ||
let reader = ByteReader(data) | ||
|
||
volumeCreationTime = reader.read() | ||
volumeSerialNumber = reader.read() | ||
volumeLabelLength = reader.read() | ||
supportsObjects = reader.read() == 1 | ||
reserved = reader.read() | ||
let volumeLabelData = reader.read(count: Int(volumeLabelLength)) | ||
volumeLabel = String(data: volumeLabelData, encoding: .utf16LittleEndian) ?? volumeLabelData.hex | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters