Skip to content

Commit

Permalink
path.ls dir init value fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uliss committed Jul 1, 2017
1 parent b3fb3e8 commit 292f761
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 45 deletions.
84 changes: 53 additions & 31 deletions ceammc/ext/doc/path.lsdir-help.pd
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,56 @@
#X obj 614 11 path.lsdir;
#X msg 50 118 symbol .;
#X msg 155 118 symbol /;
#X obj 50 162 path.lsdir;
#X obj 50 190 str.join ' ';
#X obj 50 219 str->sym;
#X msg 78 248 ;
#X obj 50 277 msg set;
#X msg 50 305 ;
#X obj 20 344 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 349 cnv 5 98 26 empty empty properties: 4 10 0 14 -262144
#X obj 299 118 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 78 147 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 299 147 path.lsdir ~ @match *.aiff;
#X obj 50 176 path.lsdir ~;
#X obj 299 176 str.join ' ';
#X obj 50 205 str.join ' ';
#X obj 299 205 str->sym;
#X obj 50 234 str->sym;
#X obj 299 234 msg set;
#X msg 78 262 ;
#X msg 299 262 ;
#X obj 50 291 msg set;
#X msg 50 320 ;
#X obj 20 359 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 364 cnv 5 90 26 empty empty arguments: 4 10 0 14 -262144
-49933 0;
#X msg 120 354 @match;
#X text 240 354 Get/Set match mask: for example *.wav for all wav
#X text 120 369 1\.;
#X text 150 369 symbol;
#X obj 241 370 cnv 1 40 18 empty empty empty 17 7 0 10 -245695 -1 0;
#X text 240 369 PATH: init directory value.;
#X obj 20 397 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 402 cnv 5 98 26 empty empty properties: 4 10 0 14 -262144
-49933 0;
#X msg 120 407 @match;
#X text 240 407 Get/Set match mask: for example *.wav for all wav
files. Type: symbol;
#X obj 20 401 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 406 cnv 5 64 26 empty empty inlets: 4 10 0 14 -262144 -49933
#X obj 20 454 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 459 cnv 5 64 26 empty empty inlets: 4 10 0 14 -262144 -49933
0;
#X text 120 411 1\.;
#X text 150 411 *bang*;
#X text 240 411 output directory content.;
#X text 150 429 *symbol*;
#X text 240 429 set directory path (symbol or string) and output it
#X text 120 464 1\.;
#X text 150 464 *bang*;
#X text 240 464 output directory content.;
#X text 150 482 *symbol*;
#X text 240 482 set directory path (symbol or string) and output it
content. If not absolute path is given list current patch directory.;
#X obj 20 485 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 490 cnv 5 73 26 empty empty outlets: 4 10 0 14 -262144
#X obj 20 538 cnv 1 685 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X obj 20 543 cnv 5 73 26 empty empty outlets: 4 10 0 14 -262144
-49933 0;
#X text 120 495 1\.;
#X text 240 495 list of strings;
#X text 120 548 1\.;
#X text 240 548 list of strings;
#X obj 10 48 ui.link @title index @url ../index-help.pd;
#X text 51 45 ::;
#X obj 67 48 ui.link @title ceammc @url ceammc-help.pd;
#X text 115 45 ::;
#X obj 131 48 ui.link @title path @url ceammc.path-help.pd;
#X obj 1 543 cnv 5 712 48 empty empty empty 17 7 0 10 -203890 -1 0;
#X text 10 546 library: ceammc v0.3;
#N canvas 10 565 400 290 info 0;
#X obj 1 596 cnv 5 712 48 empty empty empty 17 7 0 10 -203890 -1 0;
#X text 10 599 library: ceammc v0.3;
#N canvas 10 618 400 290 info 0;
#X obj 1 1 cnv 1 107 287 empty empty empty 17 7 0 10 -183085 -1 0;
#X text 10 10 library:;
#X text 120 10 ceammc;
Expand All @@ -65,11 +81,17 @@ https://github.com/uliss/pure-data;
#X obj 120 208 declare -lib ceammc -lib creammc;
#X obj 120 268 cnv 1 270 1 empty empty empty 17 7 0 10 -203890 -1 0;
#X text 120 268 generated by pddoc;
#X restore 10 565 pd info;
#X restore 10 618 pd info;
#X connect 11 0 13 0;
#X connect 5 0 10 0;
#X connect 9 0 11 0;
#X connect 5 0 7 0;
#X connect 6 0 7 0;
#X connect 10 0 11 0;
#X connect 11 0 12 0;
#X connect 8 0 9 0;
#X connect 7 0 8 0;
#X connect 10 0 12 0;
#X connect 13 0 15 0;
#X connect 12 0 14 0;
#X connect 18 0 19 0;
#X connect 8 0 10 0;
#X connect 16 0 18 0;
#X connect 15 0 17 0;
#X connect 14 0 18 0;
#X connect 6 0 10 0;
#X connect 7 0 9 0;
24 changes: 14 additions & 10 deletions ceammc/ext/doc/path.lsdir.pddoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<alias>path.ls</alias>
</aliases>
</meta>
<arguments>
<argument type="symbol" name="PATH">init directory value</argument>
</arguments>
<properties>
<property name="@match" type="symbol">match mask: for example *.wav for all wav
files</property>
Expand All @@ -33,16 +36,17 @@
<example>
<pdascii>
<![CDATA[
[symbol .( [symbol /(
| |
| |
[path.lsdir]
|
[str.join ' ']
|
[str->sym]
|
| [ (
[symbol .( [symbol /( [B]
| | |
| [B] | [path.lsdir ~ @match *.aiff]
| | | |
[path.lsdir ~] [str.join ' ']
| |
[str.join ' '] [str->sym]
| |
[str->sym] [msg set]
| |
| [ ( [ (
| |
[msg set]
|
Expand Down
6 changes: 2 additions & 4 deletions ceammc/ext/src/path/path_listdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,23 @@ PathListDir::PathListDir(const PdArgs& a)
createProperty(new PointerProperty<t_symbol*>("@match", &match_, false));

path_ = to_string(positionalArguments());
readDirList();
}

void PathListDir::onBang()
{
readDirList();
listTo(0, ls_.toList());
}

void PathListDir::onSymbol(t_symbol* path)
{
path_ = path->s_name;
readDirList();
onBang();
}

void PathListDir::onDataT(const DataTypeString& s)
{
path_ = s.str();
readDirList();
onBang();
}

Expand All @@ -64,7 +62,7 @@ void PathListDir::readDirList()

ls_.clear();

std::string path = path_;
std::string path = platform::expand_tilde_path(path_);

if (!sys_isabsolutepath(path.c_str())) {
if (cnv_) {
Expand Down
14 changes: 14 additions & 0 deletions ceammc/ext/src/tests/test_ext_path_lsdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ TEST_CASE("path.lsdir", "[externals]")
WHEN_SEND_SYMBOL_TO(0, t, TEST_DATA_DIR "non-exists");
REQUIRE_LIST_AT_OUTLET(0, t, AtomList());
}

SECTION("properties")
{
ListDirTest t("path.ls", L3(".", "@match", "*.mp3"));
REQUIRE_PROPERTY(t, @match, A("*.mp3"));

WHEN_SEND_BANG_TO(0, t);
REQUIRE_LIST_AT_OUTLET(0, t, AtomList());

WHEN_SEND_SYMBOL_TO(0, t, TEST_DATA_DIR);
REQUIRE(t.hasNewMessages(0));
REQUIRE(t.lastMessage(0).isList());
REQUIRE(to_string(t.lastMessage(0).listValue()) == "test_data0.mp3 test_data0_vbr.mp3");
}
}

SECTION("test errors")
Expand Down

0 comments on commit 292f761

Please sign in to comment.