Ejemplo n.º 1
0
void cMenuBrowseFiles::Set(void)
{
  Clear();

  if (!*m_CurrentDir)
    m_CurrentDir = m_ConfigLastDir;

  int RootDirLen = strlen(xc.media_root_dir);
  if (strncmp(m_CurrentDir, xc.media_root_dir, RootDirLen)) {
    LOGMSG("Not allowing browsing to %s (root is %s)", *m_CurrentDir, xc.media_root_dir);
    m_CurrentDir = xc.media_root_dir;
  }

  if (m_CurrentDir[0] != '/') {
#if defined(APIVERSNUM) && (APIVERSNUM < 20102)
    m_CurrentDir = VideoDirectory;
#else
    m_CurrentDir = cVideoDirectory::Name();
#endif
  }

  // find deepest accessible directory from path
  while (!ScanDir(m_CurrentDir) && strlen(m_CurrentDir) > 1) {
    m_CurrentDir = ParentDir(m_CurrentDir);
  }

  // add link to parent folder
  int CurrentDirLen = strlen(m_CurrentDir);
  if (CurrentDirLen > 1 && CurrentDirLen > RootDirLen)
    Add(new cFileListItem("..",true));

  Sort();

  SetCurrent(Get(Count()>1 && CurrentDirLen>1 ? 1 : 0));

  // select last selected item

  cString lastParent = ParentDir(m_ConfigLastDir);
  if (!strncmp(m_CurrentDir, lastParent, CurrentDirLen)) {
    cString item = LastDir(m_ConfigLastDir);
    if (*item) {
      for (cFileListItem *it = (cFileListItem*)First(); it; it = (cFileListItem*)Next(it))
        if (!strcmp(it->Name(), item))
          SetCurrent(it);
    }
  }

  strn0cpy(m_ConfigLastDir, m_CurrentDir, sizeof(xc.browse_files_dir));
  StoreConfig();

  SetHelpButtons();
  Display();
}
Ejemplo n.º 2
0
char *ziptyp(char *s)
//char *s;                /* file name to force to zip */
/* If the file name *s has a dot (other than the first char), or if
   the -A option is used (adjust self-extracting file) then return
   the name, otherwise append .zip to the name.  Allocate the space for
   the name in either case.  Return a pointer to the new name, or NULL
   if malloc() fails. */
{
  char *q;              /* temporary pointer */
  char *t;              /* pointer to malloc'ed string */
#ifdef THEOS
  char *r;              /* temporary pointer */
  char *disk;
#endif

  if ((t = (char*)malloc(strlen(s) + 5)) == NULL)
    return NULL;
  strcpy(t, s);
#ifdef __human68k__
  _toslash(t);
#endif
#ifdef MSDOS
  for (q = t; *q; INCSTR(q))
    if (*q == '\\')
      *q = '/';
#endif /* MSDOS */
#ifdef __RSXNT__   /* RSXNT/EMX C rtl uses OEM charset */
  AnsiToOem(t, t);
#endif
  if (adjust) return t;
#ifndef RISCOS
# ifndef QDOS
#  ifdef AMIGA
  if ((q = MBSRCHR(t, '/')) == NULL)
    q = MBSRCHR(t, ':');
  if (MBSRCHR((q ? q + 1 : t), '.') == NULL)
#  else /* !AMIGA */
#    ifdef THEOS
  /* the argument expansion add a dot to the end of file names when
   * there is no extension and at least one of a argument has wild cards.
   * So check for at least one character in the extension if there is a dot
   * in file name */
  if ((q = MBSRCHR((q = MBSRCHR(t, PATHCUT)) == NULL ? t : q + 1, '.')) == NULL
    || q[1] == '\0') {
#    else /* !THEOS */
#      ifdef TANDEM
  if (MBSRCHR((q = MBSRCHR(t, '.')) == NULL ? t : q + 1, ' ') == NULL)
#      else /* !TANDEM */
  if (MBSRCHR((q = MBSRCHR(t, PATHCUT)) == NULL ? t : q + 1, '.') == NULL)
#      endif /* ?TANDEM */
#    endif /* ?THEOS */
#  endif /* ?AMIGA */
#  ifdef CMS_MVS
    if (strncmp(t,"dd:",3) != 0 && strncmp(t,"DD:",3) != 0)
#  endif /* CMS_MVS */
#  ifdef THEOS
    /* insert .zip extension before disk name */
    if ((r = MBSRCHR(t, ':')) != NULL) {
        /* save disk name */
        if ((disk = strdup(r)) == NULL)
            return NULL;
        strcpy(r[-1] == '.' ? r - 1 : r, ".zip");
        strcat(t, disk);
        free(disk);
    } else {
        if (q != NULL && *q == '.')
          strcpy(q, ".zip");
        else
          strcat(t, ".zip");
    }
  }
#  else /* !THEOS */
#    ifdef TANDEM     /*  Tandem can't cope with extensions */
    strcat(t, " ZIP");
#    else /* !TANDEM */
    strcat(t, ".zip");
#    endif /* ?TANDEM */
#  endif /* ?THEOS */
# else /* QDOS */
  q = LastDir(t);
  if(MBSRCHR(q, '_') == NULL && MBSRCHR(q, '.') == NULL)
  {
      strcat(t, "_zip");
  }
# endif /* QDOS */
#endif /* !RISCOS */
  return t;
}