Modified version of the UKESF lab source which can be carried out with no knowledge of C

Fork of PsiSwarm-Headstart by UKESF Headstart Summer School

Committer:
YRL50
Date:
Fri Sep 14 16:00:48 2018 +0000
Revision:
5:f6be169e465b
Parent:
2:c6986ee3c7c5
Fixing compile warnings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:d6269d17c8cf 1 /* University of York Robotics Laboratory PsiSwarm Library: Psi-BASIC Interpretter Code
jah128 0:d6269d17c8cf 2 *
jah128 0:d6269d17c8cf 3 * File: basic.cpp
jah128 0:d6269d17c8cf 4 *
jah128 0:d6269d17c8cf 5 * (C) Dept. Electronics & Computer Science, University of York
jah128 0:d6269d17c8cf 6 * James Hilder, Alexander Horsfield, Alan Millard, Homero Elizondo, Jon Timmis
jah128 0:d6269d17c8cf 7 *
jah128 2:c6986ee3c7c5 8 * PsiSwarm Library Version: 0.41
jah128 0:d6269d17c8cf 9 *
jah128 2:c6986ee3c7c5 10 * March 2016
jah128 0:d6269d17c8cf 11 *
jah128 0:d6269d17c8cf 12 */
jah128 0:d6269d17c8cf 13
jah128 0:d6269d17c8cf 14 #include "psiswarm.h"
jah128 0:d6269d17c8cf 15
jah128 0:d6269d17c8cf 16 LocalFileSystem local("local");
jah128 0:d6269d17c8cf 17
jah128 0:d6269d17c8cf 18 void read_list_of_file_names()
jah128 0:d6269d17c8cf 19 {
jah128 0:d6269d17c8cf 20 DIR *dp;
jah128 0:d6269d17c8cf 21 struct dirent *dirp;
jah128 0:d6269d17c8cf 22 dp = opendir("/local");
jah128 0:d6269d17c8cf 23 if(dp == NULL) pc.printf("- File handling error: Failed to open directory\n");
jah128 0:d6269d17c8cf 24 debug("- Reading FLASH storage for PsiBasic files\n");
jah128 0:d6269d17c8cf 25 //read all files in MBED root directory and add matching file names in current directory into filename vector
jah128 0:d6269d17c8cf 26 while((dirp = readdir(dp)) != NULL) {
jah128 0:d6269d17c8cf 27 string filename = (string) dirp->d_name;
jah128 0:d6269d17c8cf 28 if (filename.compare(filename.size()-4,4,".PSI") == 0)
jah128 0:d6269d17c8cf 29 {
jah128 0:d6269d17c8cf 30 psi_basic_file_count ++ ;
jah128 0:d6269d17c8cf 31 debug("- Found file: %s\n",filename.c_str());
jah128 0:d6269d17c8cf 32 basic_filenames.push_back(filename);
jah128 0:d6269d17c8cf 33 }
jah128 0:d6269d17c8cf 34 }
jah128 0:d6269d17c8cf 35 closedir(dp);
jah128 0:d6269d17c8cf 36 }
jah128 0:d6269d17c8cf 37
jah128 0:d6269d17c8cf 38 //....example call in your "main" code somewhere.....
jah128 0:d6269d17c8cf 39
jah128 0:d6269d17c8cf 40 // read file names into vector of strings
jah128 0:d6269d17c8cf 41