Author Topic: Flush to disk on write on Windows 10  (Read 7700 times)

lmwilco1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Flush to disk on write on Windows 10
« on: December 02, 2018, 06:09:28 PM »
I am using SlickEdit to modify CircuitPython files on an Adafruit Feather board. When the file is written to the board the micro controller will restart the python file automatically. It looks like when I write part of my file is written but the complete file is not written for ~30 seconds. Is there a way to have SlickEdit force the OS to flush the data to the drive rather than let the OS do it when it is ready?

Thanks,
Louis

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Flush to disk on write on Windows 10
« Reply #1 on: December 03, 2018, 10:23:59 AM »
Did you see this article?
https://learn.adafruit.com/welcome-to-circuitpython/creating-and-editing-code#editing-code
You could use the drive eject thing in the Windows system tray.
You could also try this sysinternals utility
https://docs.microsoft.com/en-gb/sysinternals/downloads/sync
If it works for you, it's possible to set up slickedit to call it automatically every time you save a file or from a toolbar button click.


lmwilco1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Flush to disk on write on Windows 10
« Reply #2 on: December 04, 2018, 01:14:10 AM »
Thanks for the suggestions. Using the eject on the task bar worked as did the sync tool. Where can I look for hints on how to run the sync tool automatically when the file is saved as you suggested?

Louis

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Flush to disk on write on Windows 10
« Reply #3 on: December 04, 2018, 01:45:33 AM »
Something like this.  This is untested.
Functions that start with _cbsave_ get called automatically when a file is saved.
You could add this to your vusrmac.e file in your config folder.
If you don't have a vusrmac.e file then record a trivial macro and one will be created.

Code: [Select]
void _cbsave_do_sync()
{
   _str drive = strip_filename(p_buf_name, 'PN');
   message(drive);    // goes to status line for debug
   if ( pos(drive, 'H:') != 0 ) {
      shell('sync.exe  ','QA');
   }
}


Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Flush to disk on write on Windows 10
« Reply #4 on: December 04, 2018, 01:56:05 AM »
Forgot to say - to load macro file, use the load module command on the macro menu.

lmwilco1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Flush to disk on write on Windows 10
« Reply #5 on: December 04, 2018, 02:46:14 AM »
Still not working, it does not seem like the macro is getting called. I did load the file using the macro load menu item. I never see either of the messages in the  status line. I also search in the online help for _cbsave_do_sync and it is not found.


Code: [Select]
#include "slick.sh"
_command test() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   end_line();
   bottom_of_window();_end_line();
   bottom_of_buffer();
}

void _cbsave_do_sync()
{
   message("saving file")
   _str drive = strip_filename(p_buf_name, 'PN');
   message(drive);    // goes to status line for debug
   if ( pos(drive, 'D:') != 0 ) {
      shell('sync64.exe  D','QA');
   }
}

lmwilco1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Flush to disk on write on Windows 10
« Reply #6 on: December 04, 2018, 03:11:43 AM »
I got it to work, just a couple of modifications from your original suggestion. I never see the messages, any idea why?

Code: [Select]
void _cbsave_do_sync()
{
   message("saving file")
   _str drive = strip_filename(p_buf_name, 'N');          \
   if ( pos('D:', drive) != 0 ) {
      message(p_buf_name);    // goes to status line for debug
      shell('sync64.exe  D','QA');
   }                 
}

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Flush to disk on write on Windows 10
« Reply #7 on: December 04, 2018, 03:25:33 AM »
The message on the status line probably gets overwritten.  You could try messageNwait which waits for a keypress  -  or say('something') - which goes to a debug window.  There's also _message_box.