-
Notifications
You must be signed in to change notification settings - Fork 1
Utilities
TypNull edited this page May 8, 2024
·
1 revision
This class handles and merges the chunks of a file download.
-
RequestContainer: Type:
ProgressableContainer<GetRequest>- This property is a container for all chunks of the file download.
-
BytesWritten: Type:
long- This property represents the number of bytes that have been written to the temporary file.
-
BytesDownloaded: Type:
long- This property represents the total number of bytes that have been written to all chunk files.
-
Requests: Type:
GetRequest[]- This property gets all the requests that are in the
RequestContainer.
- This property gets all the requests that are in the
-
StartMergeTo: Type:
Task<bool>- This method merges all chunked parts of a file into one large file. The path to the destination file is passed as a parameter. The task result contains a boolean value indicating whether all chunks were successfully merged.
-
DeleteChunkFiles: Type:
Task- This method deletes the files associated with the requests up to the given count. The task represents the asynchronous operation.
Here is the continuation of the documentation for the
ChunkHandlerclass:
- This method deletes the files associated with the requests up to the given count. The task represents the asynchronous operation.
Here is the continuation of the documentation for the
-
Add: Type:
void- This method adds a
GetRequestthat represents a chunk to theRequestContainer.
- This method adds a
-
SetInfos: Type:
void- This method sets the
ContentLengthfor all chunks based on a specifiedGetRequest.
- This method sets the
-
TrySetBytesAsync: Type:
Task<bool>- This method attempts to set the number of written bytes if no bytes have been downloaded yet. The task result contains a boolean value indicating whether the operation was successful.
-
privateMergeChunks: Type:Task- This method merges the chunks of data into the specified destination. The destination file path where the chunks will be merged is passed as a parameter. Here is the continuation of the documentation for the
-
privateWriteChunkToDestination: Type:Task- This method writes a chunk of data from the specified path to the output stream.
-
privateCalculatePartialContentLength: Type:(int count, bool rest)- This method calculates the partial content length based on the number of bytes. It returns a tuple containing the count of requests and the remaining bytes.
-
privateProcessRequestsCompletion: Type:void- This method processes the requests up to the given count.
-
privatePauseAndReplaceRequest: Type:void- This method pauses and replaces the request at the given index with a new request.
This class provides utility methods for I/O operations.
-
staticInvalidFileNameChars: Type:char[]- This property represents an array of characters that are not allowed in file names.
-
staticBytesToMegabytes: Type:double- This method converts bytes to megabytes. For example, if the input is 1,048,576 bytes, the return value is 1.
-
staticRemoveInvalidFileNameChars: Type:string- This method removes all invalid characters from a file name and returns the cleaned file name.
-
staticIsValidPath: Type:bool- This method determines whether a path is valid. It returns
trueif the input path is a valid path; otherwise, it returnsfalse. It also returnsfalseif the caller does not have the required permissions to access the input path.
- This method determines whether a path is valid. It returns
-
staticTryGetFullPath: Type:bool- This method tries to get the absolute path for the specified path string. It returns
trueif the input path was converted to an absolute path successfully; otherwise, it returnsfalse.
- This method tries to get the absolute path for the specified path string. It returns
-
staticGetHomePath: Type:Nullable<string>- This method gets the home directory path. It returns the path to the home directory, or
nullif the path cannot be determined. It throws anArgumentNullExceptionwhen the environment variable for the home directory is not set on Unix platforms, and aSecurityExceptionwhen the caller does not have the required permission to perform this operation.
- This method gets the home directory path. It returns the path to the home directory, or
-
staticGetDownloadFolderPath: Type:Nullable<string>- This method gets the path to the downloads folder. It returns the path to the downloads folder, or
nullif the path cannot be determined. It throws anArgumentNullExceptionwhen the home path is null or an empty string on Unix platforms, anArgumentExceptionwhen the path to the downloads folder is not of the correct format, anIOExceptionwhen an I/O error occurs, and aSecurityExceptionwhen the caller does not have the required permission to perform this operation.
- This method gets the path to the downloads folder. It returns the path to the downloads folder, or
-
staticMove: Type:void- This method moves a file to a new location, overwriting the existing file if it exists.
-
staticCreate: Type:void- This method creates a new file or overwrites an existing file.