@@ -47,17 +47,17 @@ To connect to an FTP server and upload a file:
4747ftp = new FTP()
4848
4949try
50- ftp {
51- setHost("ftp.example.com", 21)
52- setCredentials("username", "password")
53- connect()
54- upload("local_file.txt", "remote_file.txt")
55- close()
56- }
57- ? "Upload successful!"
58-
50+ ftp {
51+ setHost("ftp.example.com", 21)
52+ setCredentials("username", "password")
53+ connect()
54+ upload("local_file.txt", "remote_file.txt")
55+ close()
56+ }
57+ ? "Upload successful!"
58+
5959catch
60- ? "Error: " + ftp.getError()
60+ ? "Error: " + ftp.getError()
6161end
6262```
6363
@@ -69,17 +69,17 @@ To download a file from an FTP server:
6969ftp = new FTP()
7070
7171try
72- ftp {
73- setHost("ftp.example.com", 21)
74- setCredentials("username", "password")
75- connect()
76- download("remote_file.txt", "local_file.txt")
77- close()
78- }
79- ? "Download complete!"
80-
72+ ftp {
73+ setHost("ftp.example.com", 21)
74+ setCredentials("username", "password")
75+ connect()
76+ download("remote_file.txt", "local_file.txt")
77+ close()
78+ }
79+ ? "Download complete!"
80+
8181catch
82- ? "Error: " + ftp.getError()
82+ ? "Error: " + ftp.getError()
8383end
8484```
8585
8989ftp = new FTP()
9090
9191try
92- ftp {
93- setHost("ftp.example.com", 21)
94- setCredentials("username", "password")
95- connect()
96-
97- # List directory contents
98- listing = listDir("/")
99- ? listing
100-
101- # Create a directory
102- mkdir("new_folder")
103-
104- # Remove a directory
105- rmdir("old_folder")
106-
107- # Delete a file
108- delete("unwanted_file.txt")
109-
110- # Rename a file
111- rename("old_name.txt", "new_name.txt")
112-
113- # Get file size
114- size = getFileSize("remote_file.txt")
115- ? "File size: " + size + " bytes"
116-
117- close()
118- }
119-
92+ ftp {
93+ setHost("ftp.example.com", 21)
94+ setCredentials("username", "password")
95+ connect()
96+
97+ # List directory contents
98+ listing = listDir("/")
99+ ? listing
100+
101+ # Create a directory
102+ mkdir("new_folder")
103+
104+ # Remove a directory
105+ rmdir("old_folder")
106+
107+ # Delete a file
108+ delete("unwanted_file.txt")
109+
110+ # Rename a file
111+ rename("old_name.txt", "new_name.txt")
112+
113+ # Get file size
114+ size = getFileSize("remote_file.txt")
115+ ? "File size: " + size + " bytes"
116+
117+ close()
118+ }
119+
120120catch
121- ? "Error: " + ftp.getError()
121+ ? "Error: " + ftp.getError()
122122end
123123```
124124
@@ -130,28 +130,28 @@ Track upload/download progress with callbacks:
130130ftp = new FTP()
131131
132132try
133- ftp {
134- setHost("ftp.example.com", 21)
135- setCredentials("username", "password")
136- setProgressCallback(:myProgressCallback)
137- connect()
138- upload("large_file.zip", "large_file.zip")
139- close()
140- }
141-
133+ ftp {
134+ setHost("ftp.example.com", 21)
135+ setCredentials("username", "password")
136+ setProgressCallback(:myProgressCallback)
137+ connect()
138+ upload("large_file.zip", "large_file.zip")
139+ close()
140+ }
141+
142142catch
143- ? "Error: " + ftp.getError()
143+ ? "Error: " + ftp.getError()
144144end
145145
146146func myProgressCallback(download_total, download_now, upload_total, upload_now)
147- if upload_total > 0
148- percent = (upload_now / upload_total) * 100
149- ? "Upload Progress: " + percent + "%"
150- ok
151- if download_total > 0
152- percent = (download_now / download_total) * 100
153- ? "Download Progress: " + percent + "%"
154- ok
147+ if upload_total > 0
148+ percent = (upload_now / upload_total) * 100
149+ ? "Upload Progress: " + percent + "%"
150+ ok
151+ if download_total > 0
152+ percent = (download_now / download_total) * 100
153+ ? "Download Progress: " + percent + "%"
154+ ok
155155```
156156
157157### Advanced Configuration
@@ -160,33 +160,33 @@ func myProgressCallback(download_total, download_now, upload_total, upload_now)
160160ftp = new FTP()
161161
162162try
163- ftp {
164- setHost("ftp.example.com", 21)
165- setCredentials("username", "password")
166-
167- # Set passive mode (default)
168- setMode(FTP_MODE_PASSIVE)
169-
170- # Enable SSL/TLS for secure transfers
171- setSSL(FTP_SSL_ALL, 1) # Verify SSL certificate
172-
173- # Set timeouts (transfer timeout, connection timeout in seconds)
174- setTimeout(60, 30)
175-
176- # Enable verbose debugging output
177- setVerbose(1)
178-
179- connect()
180-
181- # Execute custom FTP command
182- response = executeCommand("PWD")
183- ? "Current directory: " + response
184-
185- close()
186- }
187-
163+ ftp {
164+ setHost("ftp.example.com", 21)
165+ setCredentials("username", "password")
166+
167+ # Set passive mode (default)
168+ setMode(FTP_MODE_PASSIVE)
169+
170+ # Enable SSL/TLS for secure transfers
171+ setSSL(FTP_SSL_ALL, 1) # Verify SSL certificate
172+
173+ # Set timeouts (transfer timeout, connection timeout in seconds)
174+ setTimeout(60, 30)
175+
176+ # Enable verbose debugging output
177+ setVerbose(1)
178+
179+ connect()
180+
181+ # Execute custom FTP command
182+ response = executeCommand("PWD")
183+ ? "Current directory: " + response
184+
185+ close()
186+ }
187+
188188catch
189- ? "Error: " + ftp.getError()
189+ ? "Error: " + ftp.getError()
190190end
191191```
192192
@@ -309,7 +309,7 @@ Sets a function to track transfer progress.
309309ftp.setProgressCallback(:myProgressCallback)
310310
311311func myProgressCallback(download_total, download_now, upload_total, upload_now)
312- # Your progress handling code
312+ # Your progress handling code
313313```
314314
315315##### ` clearProgressCallback() `
@@ -499,42 +499,44 @@ If you wish to contribute to the development of Ring FTP or build it from the so
499499### Build Steps
500500
5015011 . ** Clone the Repository:**
502- ``` sh
503- git clone https://github.com/ysdragon/ftp.git
504- ```
505- > ** Note** : If you installed the library via RingPM, you can skip this step.
502+ ``` sh
503+ git clone https://github.com/ysdragon/ftp.git --recursive
504+ ```
505+
506+ > ** Note**
507+ > If you installed the library via RingPM, you can skip this step.
506508
5075092. ** Set the ` RING` Environment Variable:**
508- This variable must point to the root directory of the Ring language source code.
509-
510- - ** Windows (Command Prompt):**
511- ` ` ` cmd
512- set RING=X:\p ath\t o\r ing
513- ` ` `
514- - ** Windows (PowerShell):**
515- ` ` ` powershell
516- $env :RING = " X:\path\to\ring"
517- ` ` `
518- - ** Unix-like Systems (Linux, macOS or FreeBSD):**
519- ` ` ` bash
520- export RING=/path/to/ring
521- ` ` `
510+ This variable must point to the root directory of the Ring language source code.
511+
512+ - ** Windows (Command Prompt):**
513+ ` ` ` cmd
514+ set RING=X:\p ath\t o\r ing
515+ ` ` `
516+ - ** Windows (PowerShell):**
517+ ` ` ` powershell
518+ $env :RING = " X:\path\to\ring"
519+ ` ` `
520+ - ** Unix-like Systems (Linux, macOS or FreeBSD):**
521+ ` ` ` bash
522+ export RING=/path/to/ring
523+ ` ` `
522524
5235253. ** Configure with CMake:**
524- Create a build directory and run CMake from within it.
525- ` ` ` sh
526- mkdir build
527- cd build
528- cmake ..
529- ` ` `
526+ Create a build directory and run CMake from within it.
527+ ` ` ` sh
528+ mkdir build
529+ cd build
530+ cmake ..
531+ ` ` `
530532
5315334. ** Build the Project:**
532- Compile the source code using the build toolchain configured by CMake.
533- ` ` ` sh
534- cmake --build .
535- ` ` `
534+ Compile the source code using the build toolchain configured by CMake.
535+ ` ` ` sh
536+ cmake --build .
537+ ` ` `
536538
537- The compiled library will be available in the ` lib/< os> /< arch> ` directory.
539+ The compiled library will be available in the ` lib/< os> /< arch> ` directory.
538540
539541# # 🤝 Contributing
540542
0 commit comments