Esempio n. 1
0
  protected void openFile(String sFilePath, int iAccessMode) throws NexusException {
    boolean openFile = false;
    // Try to open file
    m_sFilePath = sFilePath;
    g_mutex.lock();
    g_curFile = m_sFilePath;

    try {
      // No file yet opened
      if (null == m_nfFile) {
        openFile = true;
      } else {
        // Check file isn't opened yet
        String sCurFile = "";
        try {
          sCurFile = m_nfFile.inquirefile();
        } catch (NexusException ne) {
          openFile = true;
        }

        // Check file opened is the good one and have correct write
        // access
        if (!sFilePath.equals(sCurFile) || iAccessMode != m_iAccessMode) {
          m_nfFile.close();
          openFile = true;
        }
      }

      // open the file if needed
      if (openFile) {
        open(sFilePath, iAccessMode);
        m_iAccessMode = iAccessMode;
      }

    } catch (NexusException e) {
      m_nfFile = null;
      m_sFilePath = "";
      g_curFile = "";
      g_mutex.unlock();
      throw e;
    }
  }