Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Where to place a change-log file, and how to update it


This question is answered.


Permlink Replies: 5 - Last Post: Oct 14, 2017 2:33 PM Last Post By: Antonio Estevez
Francisco Peris

Posts: 80
Registered: 1/5/15
Where to place a change-log file, and how to update it  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 7:33 AM
My app has a change-log file where the user can check the progress through the new versions, copying the content in a Memo.

When the user receives an update, a new version, the new change-log file content is displayed the first time the app is executed.

I am having a problem.

If a place the file in \assets\internal\ , then, when a new version is installed, the file is not updated. User will see the old file. I cannot understand why.

If the app is re-installed, then the new file is there.

I have tried more locations for the change-log file: ".\ " and "library\", but I cannot then find the file using Gethome or GetLibraryPath, respectively.

Any idea?

Why the content in \assets\internal\ is not updated in each new version?

Thanks in advance.
Remy Lebeau (Te...


Posts: 8,950
Registered: 12/23/01
Re: Where to place a change-log file, and how to update it [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2017 11:51 AM   in response to: Francisco Peris in response to: Francisco Peris
Francisco Peris wrote:

I have tried more locations for the change-log file: ".\ " and
"library\", but I cannot then find the file using Gethome or
GetLibraryPath, respectively.

Deploying and accessing local files on iOS and Android
https://community.embarcadero.com/article/articles-tutorials/151-ui/927-deploying-and-accessing-local-files-on-ios-and-android

Creating an Android App: Loading and Deploying Files
http://docwiki.embarcadero.com/RADStudio/en/Creating_an_Android_App#Loading_and_Deploying_Files

Use TPath.GetDocumentsPath for files deployed to 'assets/internal'.

Also, do you have the RTL's 'StartupCopy' unit in your 'uses' clause?

--
Remy Lebeau (TeamB)
Francisco Peris

Posts: 80
Registered: 1/5/15
Re: Where to place a change-log file, and how to update it [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2017 1:13 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Francisco Peris wrote:

I have tried more locations for the change-log file: ".\ " and
"library\", but I cannot then find the file using Gethome or
GetLibraryPath, respectively.

Deploying and accessing local files on iOS and Android
https://community.embarcadero.com/article/articles-tutorials/151-ui/927-deploying-and-accessing-local-files-on-ios-and-android

Creating an Android App: Loading and Deploying Files
http://docwiki.embarcadero.com/RADStudio/en/Creating_an_Android_App#Loading_and_Deploying_Files

Use TPath.GetDocumentsPath for files deployed to 'assets/internal'.

Also, do you have the RTL's 'StartupCopy' unit in your 'uses' clause?

--
Remy Lebeau (TeamB)

Hi Remy:

This a copy of the uses in the project file:

uses
  System.StartUpCopy,
  FMX.Forms,
  Unit1 in 'Unit1.pas' {Form1};


The problem here is:

I can read the files deployed in the first installation. However, when I change the content of the files in a new app version, I can only open the old file. That means that the file is not overwritten when the installation of the new app version.

How can I fix that?

Thanks in advance
Antonio Estevez

Posts: 613
Registered: 4/12/00
Re: Where to place a change-log file, and how to update it
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2017 3:49 AM   in response to: Francisco Peris in response to: Francisco Peris
El 12/10/2017 a las 10:13, Francisco Peris escribió:

This a copy of the uses in the project file:

uses
   System.StartUpCopy,
   FMX.Forms,
   Unit1 in 'Unit1.pas' {Form1};


The problem here is:

I can read the files deployed in the first installation. However, when I change the content of the files in a new app version, I can only open the old file. That means that the file is not overwritten when the installation of the new app version.

How can I fix that?

Thanks in advance

StartUpCopy does not overwrite files that already exist.

Try this:
- Copy the file System.StartUpCopy.pas from the Source\rtl\common folder to the project folder.
- Add the file to the project

- Remove the next lines from the CopyAssetToFile function:

   if not FileExists(DestFileName) then //do not overwrite files
   begin


and the matching "end;" line

On the other hand I think using StartUpCopy is not the best solution for this.
You should include the file as a resource and use the TResourceStream class to load the file.

- Select "Resources and files..." from Project menu
- Press "Add" button
- Select "All files" from the file type list
- Select the file
- Write a resource identifier for the file
- Make sure that resource type is RCDATA

- To load the file in the memo:

var
  Stream: TStream;
begin
  Stream:= TResourceStream.Create(HInstance, 'Resource_1', RT_RCDATA);
  try
    Memo1.Lines.LoadFromStream(Stream);
  finally
     Stream.Free;
  end;


where 'Resource_1' is the resource identifier you wrote

Edited by: Antonio Estevez on Oct 13, 2017 4:23 AM
Francisco Peris

Posts: 80
Registered: 1/5/15
Re: Where to place a change-log file, and how to update it  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 14, 2017 11:21 AM   in response to: Antonio Estevez in response to: Antonio Estevez
Antonio Estevez wrote:
El 12/10/2017 a las 10:13, Francisco Peris escribió:

This a copy of the uses in the project file:

uses
   System.StartUpCopy,
   FMX.Forms,
   Unit1 in 'Unit1.pas' {Form1};


The problem here is:

I can read the files deployed in the first installation. However, when I change the content of the files in a new app version, I can only open the old file. That means that the file is not overwritten when the installation of the new app version.

How can I fix that?

Thanks in advance

StartUpCopy does not overwrite files that already exist.

Try this:
- Copy the file System.StartUpCopy.pas from the Source\rtl\common folder to the project folder.
- Add the file to the project

- Remove the next lines from the CopyAssetToFile function:

   if not FileExists(DestFileName) then //do not overwrite files
   begin


and the matching "end;" line

On the other hand I think using StartUpCopy is not the best solution for this.
You should include the file as a resource and use the TResourceStream class to load the file.

- Select "Resources and files..." from Project menu
- Press "Add" button
- Select "All files" from the file type list
- Select the file
- Write a resource identifier for the file
- Make sure that resource type is RCDATA

- To load the file in the memo:

var
  Stream: TStream;
begin
  Stream:= TResourceStream.Create(HInstance, 'Resource_1', RT_RCDATA);
  try
    Memo1.Lines.LoadFromStream(Stream);
  finally
     Stream.Free;
  end;


where 'Resource_1' is the resource identifier you wrote

Edited by: Antonio Estevez on Oct 13, 2017 4:23 AM

Thanks Antonio.

I have tested both approaches and both work well.

Just two questions...

1.- why do you think the second approach is better?
2.- startupcopy only copy the files during installation of the new version, or every time the app starts?
Antonio Estevez

Posts: 613
Registered: 4/12/00
Re: Where to place a change-log file, and how to update it [Edit]
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 14, 2017 2:33 PM   in response to: Francisco Peris in response to: Francisco Peris
El 14/10/2017 a las 20:51, Francisco Peris escribió:

Thanks Antonio.

I have tested both approaches and both work well.

Just two questions...

1.- why do you think the second approach is better?

StartUpCopy should be used with files that need to be modified while using the application: configuration, databases,
etc. For this reason they are copied to a folder with write permissions.
Files that are not to be modified should be included as resources.

2.- startupcopy only copy the files during installation of the new version, or every time the app starts?

StartUpCopy runs every time the application starts. For this reason, it does not overwrite files that already exist in
the destination folder. If this were done the changes that could have been made in those files would be lost.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02