InetGet not working as expected - download

I wrote a simple patcher application which downloads a file into configured directory.
When I download some files from the URL via patcher, application which the dll file belongs to doesn't run (when I click 'open' nothing happens). Here is my code cut:
Local $fileDownload = InetGet("http://myurl.com/library.dll" , "library.dll" , 1 , 1)
Everything is fine, and if I remove the library.dll AutoIt is downloading it, but then the main application doesn't run.
If I download and replace the file manually (via web browser) everything is fine. So looks like InetGet() corrupts the file. But I don't know how and why.

inet_get should work! anyway here is another aproach download the file directly with winapi method using my function than save it to a file
Func get_url($url)
$RequestURL = $url;
Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;
$oHTTP.Open("GET", $RequestURL, False)
$oHTTP.Send()
if $oHTTP.status == 200 Then
Return $oHTTP.ResponseText
Else
Return "ooops... status: " & $oHTTP.status
EndIf
EndFunc

Related

How to get current working dir on MacOs in compose desktop

I wanna get current working dir, in order to call some commands. I copied code from jetpack compose desktop lib's demo, but got wrong dir("/"). Could any one tell me what's the problem? thank you.
(jetpack compose desktop lib: https://github.com/JetBrains/compose-jb/blob/master/tutorials/Native_distributions_and_local_execution/README.md)
val userDirStr = File(System.getProperty("user.dir"))
if (userDirStr != null) {
println("Row, onGloballyPositioned, userDirStr = " + userDirStr)
outputText = "directory = " + userDirStr
}
I build a new Compose Crossplatform project, and copy old code into it.
Then "File(System.getProperty("compose.application.resources.dir"))" just got the right path.

How to download a file to a specific location?

I want to download an image to the "Music" folder but it downloads to where AutoIt (.exe) is placed. If AutoIt.exe is in "Desktop" folder it will download to there.
My code:
Local $hDownload = InetGet("https://media.com/abc.jpg", "abc.jpg", 1, 1)
Sleep(250)
Do
Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
Sleep(1000)
I want to download the image to my desired location.
just give it the fully qualified filename (including the path):
Local $hDownload = InetGet("https://media.com/abc.jpg","C:\my desired\folder\abc.jpg", 1 , 1)
It's better readable and maintainable when you use variables. The following code works for me:
$url="https://www.google.de/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
$file=#StartupDir&"\test.png"
$hDownload=InetGet($url,$file)
if $hDownload = 0 then ConsoleWrite("Download failed." & #CRLF)

open file with shell() in R

I want to open a file in a windows program using R, but specifying the program rather than the default for the file extension, and for a file not necesarrily in my current R session home directory (this one getwd())
From looking at the documentation, using shell(), should be the way, but I seem to have an issue with the way R references the home directory or the way I'm writing the string.
e.g.
This works ok in the cmd "run" in windows: excel e:\test.xlsx
but using this
route <- "e:\\test.xlsx"
shell(paste("excel " , route, sep=""), flag="")
seems to get to excel (excel copyright notice is printed), but also prints the home directory and doesn't open the file in route. Thanks for any help.
Your command does the same for me. However, this works:
shell(paste("start", "excel", route))

How to include file as resource in Xcode programmatically during build?

I have a file that is created by a script that is run during a build phase. Consequently, the file does not exist until build time.
How can I add the file to the app/project so that my code can access it at run time?
I know what the filename will be.
Normally, if I created the file by hand, I would just drag/drop it into Xcode, and I can instantly access it by using the filename in code. Since I am generating the file during build, I want to know how I can add it to my project.
EDIT: The file that I am adding is an Image file, that is created by a script during a build phase. I want to be able to access this file at runtime in my product.
I ended up using build references.
You could create the file and add it to the project and then during the build phase, your script could replace the existing file with the generated one....
The other option is to try manipulating the project file itself but that's quite complicated. Here are some resources on the subject...
You can copy the generated file to the build output using a script like this one I use to copy a plist with values maintained outside version control, as anything copied to "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/" is available using NSBundle APIs.
SECRETS="${SRCROOT}/../../secrets/Secrets.plist"
APP="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}/Secrets.plist"
if [ -f "$SECRETS" ]; then
cp -f "$SECRETS" "$APP"
echo "copied Secrets.plist: $APP"
else
echo "Secrets.plist not found at $SECRETS, all secrets will be 'MISSING'"
fi
For instance, that plist of secrets is defined as the Decodable struct SecretsFile and loaded with
private static var file: SecretsFile? = {
guard let url = Bundle.main.url(forResource: "Secrets", withExtension: "plist"),
let data = try? Data(contentsOf: url) else { return nil }
return try? PropertyListDecoder().decode(SecretsFile.self, from: data)
}()

Storing cache using .manifest file doesn't work

I'm currently developing a Web app for the iPad.
So I created the whole "application", with my different html files, my css, my pictures.
Now the next step for me is to be able to cache the files to use the "application" offline.
I follow the advices I found on different websites, with the manifest file and everything.
It seems I'm the only one with this issue, because I searched on Internet an answer to my issue, but I didn't find anything.
So I created my manifest file (ipad.manifest) which looks like this :
$CACHE MANIFEST
$/WebApp/home-start.htm
$/WebApp/accommodation.htm
$/WebApp/accommodation2.htm
$/WebApp/dining.htm
$/WebApp/entertainment.htm
$/WebApp/general.htm
$/WebApp/home.htm
$/WebApp/shopping.htm
$/WebApp/sights.htm
$/WebApp/sports.htm
$/WebApp/css/screen3.css
$/WebApp/Player/CanalVenetian.mp4
$/WebApp/Player/DancingWater.mp4
$/WebApp/Player/NaCha.mp4
$/WebApp/Player/NaCha2.mp4
$/WebApp/Player/Opening.mp4
$/WebApp/Player/previewhome.jpg
$/WebApp/Player/previewsights.jpg
$/WebApp/Player/previewvenetian.jpg
$/WebApp/Player/Venetian.mp4
$/WebApp/Player/video.js
$/WebApp/Player/Zaia.mp4
$/WebApp/iPad/startup.png
$/WebApp/iPad/pixel.gif
$/WebApp/iPad/asktt-ipad-accommodation2.jpg
$/WebApp/iPad/asktt-ipad-camera.jpg
$....
I tried with both, relative and absolute links, and it's still not working.
And in every html files I added :
$<!DOCTYPE html>
$<html manifest="ipad.manifest">
$<head>
When I go to the website with the iPad and click on "add to home screen", it adds the icon on the home screen but didn't download the content. So each time I open the application it starts to load everything....
When I tried on desktop browsers it didn't ask me to cache the content on my computer.
I added an header "content/type : text/manifest" for my mime type files on my server.
But I don't understand why it doesn't cache anything, or doesn't even ask me if I want to cache the files???
Does someone have an idea ? Or had the same issue ?
try with this, put it on the root of your app and name it manifest.php and add it to your html web app with
php file start here
$hashes="";
$dir = new RecursiveDirectoryIterator(".");
foreach(new RecursiveIteratorIterator($dir) as $file){
if ($file->IsFile() &&
$file != "./manifest.php" &&
substr($file->getFilename(),0,1) != ".")
{
echo $file . "\n";
$hashes .= md5_file($file);
}
}
echo "# Hash:" . md5($hashes) . "\n";
?>
php file ends here

Resources