Jump to content

wpSetRefreshFlags

From EDM2

This method is specific to Version 4, or higher, of the OS/2 operating system.

This instance method sets the refresh flags for a file system object.

Syntax

_wpSetRefreshFlags(somSelf, ulRefreshFlags)

Parameters

somSelf (WPFileSystem *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPFileSystem.
ulRefreshFlags (ULONG) - input
New **DIRTYBIT** and **FOUNDBIT** settings.
  • **DIRTYBIT** (0x80000000) Used for refreshing the views of pre-existing objects.
  • **FOUNDBIT** (0x40000000) Used for refreshing the views of new and deleted objects.

Returns

rc (BOOL) - returns
Success indicator
  • TRUE Successful completion.
  • FALSE Error occurred.

How to Override

This method is not generally overridden.

Usage

You can call the **wpSetRefreshFlags** method at any time to set the refresh flags for a file system object.

Remarks

You should only call the **wpSetRefreshFlags** method only at a time when your object class is controlling the process of refreshing a folder. For example, if you have overridden the **wpRefresh** method for a subclass of **WPFolder**, you can set and query the refresh flags while your **wpRefresh** method is in control. You should not try to modify the refresh flags while the Workplace Shell's **wpRefresh** method is in control.

The refresh flags consist of a **DIRTYBIT** and a **FOUNDBIT** that are used to detect deleted files and new files when refreshing the contents of a folder. This technique can be used to synchronize a folder with an external data source (like a database).

Example Code

#define INCL_WINWORKPLACE
#include <os2.h>

WPFileSystem *somSelf; /* Pointer to the object on which the method is being invoked. */
ULONG ulRefreshFlags; /* New DIRTYBIT and FOUNDBIT settings. */
BOOL rc; /* Success indicator */

rc = _wpSetRefreshFlags(somSelf, ulRefreshFlags);

This example shows how you can use the refresh flags to synchronize the contents of a folder with the contents of a data base. somSelf is the pointer to the folder containing the objects corresponding to the items in the data base.

    MyObject  *Object,*NextObject;

    /* Mark all existing objects as not found  */
    Object = (MyObject*)_wpQueryContent(somSelf,NULL,QC_FIRST);
    while (Object)
    {
      _wpSetRefreshFlags(Object,0);
      Object = (MyObject*)_wpQueryContent(somSelf,Object,QC_NEXT);
    }

    /* Loop through the data base. For each item in the data base, find the
     * corresponding object and call the wpSetRefreshFlags method for the
     * object to set FOUNDBIT on. For any item that does not have a
     * corresponding object, create the object and call the wpSetRefreshFlags
     * method for the new object to set the FOUNDBIT on.  */

    /***** The code for the above described loop goes here *****/

    /* Remove all objects corresponding to data base entries that have been
     * deleted from the data base */
    Object = (MyObject*)_wpQueryContent(somSelf,NULL,QC_FIRST);
    while (Object)
    {
      NextObject = (MyObject*)_wpQueryContent(somSelf,Object,QC_NEXT);
      ulFlags = _wpQueryRefreshFlags(Object);
      if (!(ulFlags & FOUNDBIT))
      {
         Object->wpDelete(0);
      }
      Object = NextObject;
    }

Related Methods