Trouble with Paths? - delphi

I have a problem where I am creating an Android app using Firemonkey in Delphi XE6. The app consists of a TWebBrowser and a button...nothing fancy.
I am TRYING to display an xhtml file that is located on my SD card.
I "think" I am doing all the right things like using "TPath.GetHomePath" and putting my file in this location. - and made sure the permissions are set in the project.
Being a seasoned developer, I know that I need to use "file://" so the browser knows it a local file, as I have done a million times in Delphi over the years, and even checking the help file which uses the example "WebBrowser1.Navigate('file://MyFile.pdf')"
So I construct my URL by doing :
AppPath := TPath.Combine(TPath.GetHomePath, 'myfile.xhtml');
I then go:
WebBrowser1.Navigate('file://'+AppPath);
When the navigation happens, it tells me the file doesn't exist, file:///data/data/com.embarcadero.WebBrowser/files/myfile.xhtml
I spotted the 3 /'s i.e. file:/// and thought I would just hard coded the path into a string and got the same problem saying the file doesn't exists and it reverting back to file:///
Can anyone see what I am doing wrong? its got me puzzled thats for sure! :-)
Thanks, Jeremy

Instead of
TPath.GetHomePath
i used
TPath.GetPublicPath
which leads me to /storage/emulated/0/Android/data/<myapp>/files/ folder (the one i need).
TPath.GetHomePath
gives me data/data/<myapp>/files/ which is not exists (i guess, maybe i need something like GetAbsolutePath).

Related

Blink.jl load(loadjs!/loadcss!/importhtml!) functions not working correctly

I hope someone here has used the Blink.jl package for building Julia and Electron apps.
I am having problems setting up and using it, though. The issue is with all of the functions in the api provided: load/loadcss/loadjs/importhtml. They do not seem to work, or I might be doing something wrong.
For example:
loadcss!(w, "styles.css")
does not apply any of the styles in the styles files in the directory.
importhtml!(w, 'index.html')
does not display the html page stored in the local directory. The app shows a blank screen.
I might be doing something wrong as i could not find documentation on how to use the package
I think I found out why, the methods take the full path and not the relative paths, even if files are inside the same folder. So, something like this works:
loadcss!(w, "D:\project\styles.css")
but this won't work:
loadcss!(w, "styles.css")

Code that can look at open browser tabs and store the urls?

I am attempting to write a program that looks at the current browser you have open, goes through each tab, and copies and pastes each page's url into a notepad file.
I have no issue with writing the file; my main concern is that I can't find anything in any language that can look at the browser, sift through the tabs, and scrape the url.
Does anyone know if this would be possible, any code that might be able to help (in any language), or if something like this exists? I would appreciate anyone pointing me in the right direction.
The software I was looking for did not exist, so I created it. It's a chrome extension called Raincheck

How to get a content of file which is being written by an application?

This application always create a file when you activate a function (lets say, a log file). This file cannot be opened during the running - but I need its content before application closes (another process uses it, so I cant even view it). Is there a way to "hook" it somehow?
Im working with Delphi, but I accept any other solution.
So, summary, I need to know what file application created (it always creates other, but in the same directory) and the content it wrote. Any help appreciated.
I found a workaround:
copy the file, and operate on the cloned one:
http://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/

Need to detect if a url contains a certain folder and if it does strip that folder out

We recently moved our communities to the cloud and with that we moved all subfolders up one level.
So, previously we had:
www.mywebsite.com/abcd/otherstuff/index.htm
And now our folder structure is:
www.mywebsite.com/otherstuff/index.htm
We've stripped out the abcd from all URLS in the website itself. The problem is, there's lots of tech notes and bookmarks out there in the world that still point to the old URL and they are getting a 404 and a lot of people are not happy.
Is it possible to write a script that enables our communities to detect the presence of abcd in the URL, strip it out, parse the remainder and direct the browser to the correct address?
What language would one write this in? Would it go in the HTTACCESS file? Has anyone done anything similar before?
Thanks.
I haven't done it but you may find this information useful: http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/

File name encoding at Knoppix

I am getting file list in my Java program using list() method of File class. When I run my program on Knoppix I get ???? instead of Cyrillic file names. It seems that problem is in knoppix, not java. I tried to use options for mounting file system, such as nls and iocharset, but it has no effect (or may be I use it in wrong way). Somebody can help me?
I think that problem is as you said with Knoppix. Probably you do not have Cyrillic font bundled, so there is no way to display these code points.
If you want to fix this, you will need fix distribution, as there is nothing wrong with the program. I am not sure if this is the question for https://serverfault.com/ or https://superuser.com/, but you can read their FAQ's and ask how to fix it there (probably you will need to re-create Knoppix distribution).

Resources